shared-definitions.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. import gql from 'graphql-tag';
  2. import {
  3. ADMINISTRATOR_FRAGMENT,
  4. ASSET_FRAGMENT,
  5. COLLECTION_FRAGMENT,
  6. COUNTRY_FRAGMENT,
  7. CURRENT_USER_FRAGMENT,
  8. CUSTOMER_FRAGMENT,
  9. FACET_WITH_VALUES_FRAGMENT,
  10. ORDER_FRAGMENT,
  11. ORDER_WITH_LINES_FRAGMENT,
  12. PRODUCT_VARIANT_FRAGMENT,
  13. PRODUCT_WITH_VARIANTS_FRAGMENT,
  14. PROMOTION_FRAGMENT,
  15. ROLE_FRAGMENT,
  16. TAX_RATE_FRAGMENT,
  17. VARIANT_WITH_STOCK_FRAGMENT,
  18. } from './fragments';
  19. export const CREATE_ADMINISTRATOR = gql`
  20. mutation CreateAdministrator($input: CreateAdministratorInput!) {
  21. createAdministrator(input: $input) {
  22. ...Administrator
  23. }
  24. }
  25. ${ADMINISTRATOR_FRAGMENT}
  26. `;
  27. export const UPDATE_PRODUCT = gql`
  28. mutation UpdateProduct($input: UpdateProductInput!) {
  29. updateProduct(input: $input) {
  30. ...ProductWithVariants
  31. }
  32. }
  33. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  34. `;
  35. export const CREATE_PRODUCT = gql`
  36. mutation CreateProduct($input: CreateProductInput!) {
  37. createProduct(input: $input) {
  38. ...ProductWithVariants
  39. }
  40. }
  41. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  42. `;
  43. export const GET_PRODUCT_WITH_VARIANTS = gql`
  44. query GetProductWithVariants($id: ID, $slug: String) {
  45. product(slug: $slug, id: $id) {
  46. ...ProductWithVariants
  47. }
  48. }
  49. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  50. `;
  51. export const GET_PRODUCT_LIST = gql`
  52. query GetProductList($options: ProductListOptions) {
  53. products(options: $options) {
  54. items {
  55. id
  56. languageCode
  57. name
  58. slug
  59. featuredAsset {
  60. id
  61. preview
  62. }
  63. }
  64. totalItems
  65. }
  66. }
  67. `;
  68. export const CREATE_PRODUCT_VARIANTS = gql`
  69. mutation CreateProductVariants($input: [CreateProductVariantInput!]!) {
  70. createProductVariants(input: $input) {
  71. ...ProductVariant
  72. }
  73. }
  74. ${PRODUCT_VARIANT_FRAGMENT}
  75. `;
  76. export const UPDATE_PRODUCT_VARIANTS = gql`
  77. mutation UpdateProductVariants($input: [UpdateProductVariantInput!]!) {
  78. updateProductVariants(input: $input) {
  79. ...ProductVariant
  80. }
  81. }
  82. ${PRODUCT_VARIANT_FRAGMENT}
  83. `;
  84. export const UPDATE_TAX_RATE = gql`
  85. mutation UpdateTaxRate($input: UpdateTaxRateInput!) {
  86. updateTaxRate(input: $input) {
  87. ...TaxRate
  88. }
  89. }
  90. ${TAX_RATE_FRAGMENT}
  91. `;
  92. export const CREATE_FACET = gql`
  93. mutation CreateFacet($input: CreateFacetInput!) {
  94. createFacet(input: $input) {
  95. ...FacetWithValues
  96. }
  97. }
  98. ${FACET_WITH_VALUES_FRAGMENT}
  99. `;
  100. export const UPDATE_FACET = gql`
  101. mutation UpdateFacet($input: UpdateFacetInput!) {
  102. updateFacet(input: $input) {
  103. ...FacetWithValues
  104. }
  105. }
  106. ${FACET_WITH_VALUES_FRAGMENT}
  107. `;
  108. export const GET_CUSTOMER_LIST = gql`
  109. query GetCustomerList($options: CustomerListOptions) {
  110. customers(options: $options) {
  111. items {
  112. id
  113. title
  114. firstName
  115. lastName
  116. emailAddress
  117. phoneNumber
  118. user {
  119. id
  120. verified
  121. }
  122. }
  123. totalItems
  124. }
  125. }
  126. `;
  127. export const GET_ASSET_LIST = gql`
  128. query GetAssetList($options: AssetListOptions) {
  129. assets(options: $options) {
  130. items {
  131. ...Asset
  132. }
  133. totalItems
  134. }
  135. }
  136. ${ASSET_FRAGMENT}
  137. `;
  138. export const CREATE_ROLE = gql`
  139. mutation CreateRole($input: CreateRoleInput!) {
  140. createRole(input: $input) {
  141. ...Role
  142. }
  143. }
  144. ${ROLE_FRAGMENT}
  145. `;
  146. export const CREATE_COLLECTION = gql`
  147. mutation CreateCollection($input: CreateCollectionInput!) {
  148. createCollection(input: $input) {
  149. ...Collection
  150. }
  151. }
  152. ${COLLECTION_FRAGMENT}
  153. `;
  154. export const UPDATE_COLLECTION = gql`
  155. mutation UpdateCollection($input: UpdateCollectionInput!) {
  156. updateCollection(input: $input) {
  157. ...Collection
  158. }
  159. }
  160. ${COLLECTION_FRAGMENT}
  161. `;
  162. export const GET_CUSTOMER = gql`
  163. query GetCustomer($id: ID!, $orderListOptions: OrderListOptions) {
  164. customer(id: $id) {
  165. ...Customer
  166. orders(options: $orderListOptions) {
  167. items {
  168. id
  169. code
  170. state
  171. total
  172. currencyCode
  173. updatedAt
  174. }
  175. totalItems
  176. }
  177. }
  178. }
  179. ${CUSTOMER_FRAGMENT}
  180. `;
  181. export const ATTEMPT_LOGIN = gql`
  182. mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean) {
  183. login(username: $username, password: $password, rememberMe: $rememberMe) {
  184. user {
  185. ...CurrentUser
  186. }
  187. }
  188. }
  189. ${CURRENT_USER_FRAGMENT}
  190. `;
  191. export const GET_COUNTRY_LIST = gql`
  192. query GetCountryList($options: CountryListOptions) {
  193. countries(options: $options) {
  194. items {
  195. id
  196. code
  197. name
  198. enabled
  199. }
  200. totalItems
  201. }
  202. }
  203. `;
  204. export const UPDATE_COUNTRY = gql`
  205. mutation UpdateCountry($input: UpdateCountryInput!) {
  206. updateCountry(input: $input) {
  207. ...Country
  208. }
  209. }
  210. ${COUNTRY_FRAGMENT}
  211. `;
  212. export const GET_FACET_LIST = gql`
  213. query GetFacetList($options: FacetListOptions) {
  214. facets(options: $options) {
  215. items {
  216. ...FacetWithValues
  217. }
  218. totalItems
  219. }
  220. }
  221. ${FACET_WITH_VALUES_FRAGMENT}
  222. `;
  223. export const DELETE_PRODUCT = gql`
  224. mutation DeleteProduct($id: ID!) {
  225. deleteProduct(id: $id) {
  226. result
  227. }
  228. }
  229. `;
  230. export const GET_PRODUCT_SIMPLE = gql`
  231. query GetProductSimple($id: ID, $slug: String) {
  232. product(slug: $slug, id: $id) {
  233. id
  234. slug
  235. }
  236. }
  237. `;
  238. export const GET_STOCK_MOVEMENT = gql`
  239. query GetStockMovement($id: ID!) {
  240. product(id: $id) {
  241. id
  242. variants {
  243. ...VariantWithStock
  244. }
  245. }
  246. }
  247. ${VARIANT_WITH_STOCK_FRAGMENT}
  248. `;
  249. export const GET_RUNNING_JOBS = gql`
  250. query GetRunningJobs($options: JobListOptions) {
  251. jobs(options: $options) {
  252. items {
  253. id
  254. queueName
  255. state
  256. isSettled
  257. duration
  258. }
  259. totalItems
  260. }
  261. }
  262. `;
  263. export const CREATE_PROMOTION = gql`
  264. mutation CreatePromotion($input: CreatePromotionInput!) {
  265. createPromotion(input: $input) {
  266. ...Promotion
  267. }
  268. }
  269. ${PROMOTION_FRAGMENT}
  270. `;
  271. export const ME = gql`
  272. query Me {
  273. me {
  274. ...CurrentUser
  275. }
  276. }
  277. ${CURRENT_USER_FRAGMENT}
  278. `;
  279. export const CREATE_CHANNEL = gql`
  280. mutation CreateChannel($input: CreateChannelInput!) {
  281. createChannel(input: $input) {
  282. id
  283. code
  284. token
  285. currencyCode
  286. defaultLanguageCode
  287. defaultShippingZone {
  288. id
  289. }
  290. defaultTaxZone {
  291. id
  292. }
  293. pricesIncludeTax
  294. }
  295. }
  296. `;
  297. export const DELETE_PRODUCT_VARIANT = gql`
  298. mutation DeleteProductVariant($id: ID!) {
  299. deleteProductVariant(id: $id) {
  300. result
  301. message
  302. }
  303. }
  304. `;
  305. export const ASSIGN_PRODUCT_TO_CHANNEL = gql`
  306. mutation AssignProductsToChannel($input: AssignProductsToChannelInput!) {
  307. assignProductsToChannel(input: $input) {
  308. ...ProductWithVariants
  309. }
  310. }
  311. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  312. `;
  313. export const REMOVE_PRODUCT_FROM_CHANNEL = gql`
  314. mutation RemoveProductsFromChannel($input: RemoveProductsFromChannelInput!) {
  315. removeProductsFromChannel(input: $input) {
  316. ...ProductWithVariants
  317. }
  318. }
  319. ${PRODUCT_WITH_VARIANTS_FRAGMENT}
  320. `;
  321. export const UPDATE_ASSET = gql`
  322. mutation UpdateAsset($input: UpdateAssetInput!) {
  323. updateAsset(input: $input) {
  324. ...Asset
  325. ... on Asset {
  326. focalPoint {
  327. x
  328. y
  329. }
  330. }
  331. }
  332. }
  333. ${ASSET_FRAGMENT}
  334. `;
  335. export const DELETE_ASSET = gql`
  336. mutation DeleteAsset($id: ID!, $force: Boolean) {
  337. deleteAsset(id: $id, force: $force) {
  338. result
  339. message
  340. }
  341. }
  342. `;
  343. export const UPDATE_CHANNEL = gql`
  344. mutation UpdateChannel($input: UpdateChannelInput!) {
  345. updateChannel(input: $input) {
  346. id
  347. code
  348. defaultLanguageCode
  349. currencyCode
  350. }
  351. }
  352. `;
  353. export const GET_CUSTOMER_HISTORY = gql`
  354. query GetCustomerHistory($id: ID!, $options: HistoryEntryListOptions) {
  355. customer(id: $id) {
  356. id
  357. history(options: $options) {
  358. totalItems
  359. items {
  360. id
  361. administrator {
  362. id
  363. }
  364. type
  365. data
  366. }
  367. }
  368. }
  369. }
  370. `;
  371. export const GET_ORDER = gql`
  372. query GetOrder($id: ID!) {
  373. order(id: $id) {
  374. ...OrderWithLines
  375. }
  376. }
  377. ${ORDER_WITH_LINES_FRAGMENT}
  378. `;
  379. export const CUSTOMER_GROUP_FRAGMENT = gql`
  380. fragment CustomerGroup on CustomerGroup {
  381. id
  382. name
  383. customers {
  384. items {
  385. id
  386. }
  387. totalItems
  388. }
  389. }
  390. `;
  391. export const CREATE_CUSTOMER_GROUP = gql`
  392. mutation CreateCustomerGroup($input: CreateCustomerGroupInput!) {
  393. createCustomerGroup(input: $input) {
  394. ...CustomerGroup
  395. }
  396. }
  397. ${CUSTOMER_GROUP_FRAGMENT}
  398. `;
  399. export const REMOVE_CUSTOMERS_FROM_GROUP = gql`
  400. mutation RemoveCustomersFromGroup($groupId: ID!, $customerIds: [ID!]!) {
  401. removeCustomersFromGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  402. ...CustomerGroup
  403. }
  404. }
  405. ${CUSTOMER_GROUP_FRAGMENT}
  406. `;
  407. export const CREATE_FULFILLMENT = gql`
  408. mutation CreateFulfillment($input: FulfillOrderInput!) {
  409. fulfillOrder(input: $input) {
  410. id
  411. method
  412. state
  413. trackingCode
  414. orderItems {
  415. id
  416. }
  417. }
  418. }
  419. `;
  420. export const TRANSIT_FULFILLMENT = gql`
  421. mutation TransitFulfillment($id: ID!, $state: String!) {
  422. transitionFulfillmentToState(id: $id, state: $state) {
  423. id
  424. state
  425. }
  426. }
  427. `;
  428. export const GET_ORDER_FULFILLMENTS = gql`
  429. query GetOrderFulfillments($id: ID!) {
  430. order(id: $id) {
  431. id
  432. state
  433. fulfillments {
  434. id
  435. state
  436. nextStates
  437. method
  438. }
  439. }
  440. }
  441. `;
  442. export const GET_ORDERS_LIST = gql`
  443. query GetOrderList($options: OrderListOptions) {
  444. orders(options: $options) {
  445. items {
  446. ...Order
  447. }
  448. totalItems
  449. }
  450. }
  451. ${ORDER_FRAGMENT}
  452. `;
  453. export const CREATE_ADDRESS = gql`
  454. mutation CreateAddress($id: ID!, $input: CreateAddressInput!) {
  455. createCustomerAddress(customerId: $id, input: $input) {
  456. id
  457. fullName
  458. company
  459. streetLine1
  460. streetLine2
  461. city
  462. province
  463. postalCode
  464. country {
  465. code
  466. name
  467. }
  468. phoneNumber
  469. defaultShippingAddress
  470. defaultBillingAddress
  471. }
  472. }
  473. `;
  474. export const UPDATE_ADDRESS = gql`
  475. mutation UpdateAddress($input: UpdateAddressInput!) {
  476. updateCustomerAddress(input: $input) {
  477. id
  478. defaultShippingAddress
  479. defaultBillingAddress
  480. country {
  481. code
  482. name
  483. }
  484. }
  485. }
  486. `;
  487. export const CREATE_CUSTOMER = gql`
  488. mutation CreateCustomer($input: CreateCustomerInput!, $password: String) {
  489. createCustomer(input: $input, password: $password) {
  490. ...Customer
  491. }
  492. }
  493. ${CUSTOMER_FRAGMENT}
  494. `;
  495. export const UPDATE_CUSTOMER = gql`
  496. mutation UpdateCustomer($input: UpdateCustomerInput!) {
  497. updateCustomer(input: $input) {
  498. ...Customer
  499. }
  500. }
  501. ${CUSTOMER_FRAGMENT}
  502. `;
  503. export const DELETE_CUSTOMER = gql`
  504. mutation DeleteCustomer($id: ID!) {
  505. deleteCustomer(id: $id) {
  506. result
  507. }
  508. }
  509. `;
  510. export const UPDATE_CUSTOMER_NOTE = gql`
  511. mutation UpdateCustomerNote($input: UpdateCustomerNoteInput!) {
  512. updateCustomerNote(input: $input) {
  513. id
  514. data
  515. isPublic
  516. }
  517. }
  518. `;
  519. export const DELETE_CUSTOMER_NOTE = gql`
  520. mutation DeleteCustomerNote($id: ID!) {
  521. deleteCustomerNote(id: $id) {
  522. result
  523. message
  524. }
  525. }
  526. `;
  527. export const UPDATE_CUSTOMER_GROUP = gql`
  528. mutation UpdateCustomerGroup($input: UpdateCustomerGroupInput!) {
  529. updateCustomerGroup(input: $input) {
  530. ...CustomerGroup
  531. }
  532. }
  533. ${CUSTOMER_GROUP_FRAGMENT}
  534. `;
  535. export const DELETE_CUSTOMER_GROUP = gql`
  536. mutation DeleteCustomerGroup($id: ID!) {
  537. deleteCustomerGroup(id: $id) {
  538. result
  539. message
  540. }
  541. }
  542. `;
  543. export const GET_CUSTOMER_GROUPS = gql`
  544. query GetCustomerGroups($options: CustomerGroupListOptions) {
  545. customerGroups(options: $options) {
  546. items {
  547. id
  548. name
  549. }
  550. totalItems
  551. }
  552. }
  553. `;
  554. export const GET_CUSTOMER_GROUP = gql`
  555. query GetCustomerGroup($id: ID!, $options: CustomerListOptions) {
  556. customerGroup(id: $id) {
  557. id
  558. name
  559. customers(options: $options) {
  560. items {
  561. id
  562. }
  563. totalItems
  564. }
  565. }
  566. }
  567. `;
  568. export const ADD_CUSTOMERS_TO_GROUP = gql`
  569. mutation AddCustomersToGroup($groupId: ID!, $customerIds: [ID!]!) {
  570. addCustomersToGroup(customerGroupId: $groupId, customerIds: $customerIds) {
  571. ...CustomerGroup
  572. }
  573. }
  574. ${CUSTOMER_GROUP_FRAGMENT}
  575. `;
  576. export const GET_CUSTOMER_WITH_GROUPS = gql`
  577. query GetCustomerWithGroups($id: ID!) {
  578. customer(id: $id) {
  579. id
  580. groups {
  581. id
  582. name
  583. }
  584. }
  585. }
  586. `;
  587. export const ADMIN_TRANSITION_TO_STATE = gql`
  588. mutation AdminTransition($id: ID!, $state: String!) {
  589. transitionOrderToState(id: $id, state: $state) {
  590. ...Order
  591. ... on OrderStateTransitionError {
  592. errorCode: code
  593. message
  594. transitionError
  595. fromState
  596. toState
  597. }
  598. }
  599. }
  600. ${ORDER_FRAGMENT}
  601. `;