decap-cms-backend-github 3.2.3-beta.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,96 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var React = _interopRequireWildcard(require("react"));
8
- var _semaphore = _interopRequireDefault(require("semaphore"));
9
- var _trimStart = _interopRequireDefault(require("lodash/trimStart"));
10
- var _commonTags = require("common-tags");
11
- var _decapCmsLibUtil = require("decap-cms-lib-util");
12
- var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
13
- var _API = _interopRequireWildcard(require("./API"));
14
- var _GraphQLAPI = _interopRequireDefault(require("./GraphQLAPI"));
15
- var _react2 = require("@emotion/react");
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
24
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import * as React from 'react';
3
+ import semaphore from 'semaphore';
4
+ import trimStart from 'lodash/trimStart';
5
+ import { stripIndent } from 'common-tags';
6
+ import { CURSOR_COMPATIBILITY_SYMBOL, Cursor, asyncLock, basename, getBlobSHA, entriesByFolder, entriesByFiles, unpublishedEntries, getMediaDisplayURL, getMediaAsBlob, filterByExtension, getPreviewStatus, runWithLock, blobToFileObj, contentKeyFromBranch, unsentRequest, branchFromContentKey } from 'decap-cms-lib-util';
7
+ import AuthenticationPage from './AuthenticationPage';
8
+ import API, { API_NAME } from './API';
9
+ import GraphQLAPI from './GraphQLAPI';
10
+ import { jsx as ___EmotionJSX } from "@emotion/react";
25
11
  const MAX_CONCURRENT_DOWNLOADS = 10;
26
12
  const {
27
13
  fetchWithTimeout: fetch
28
- } = _decapCmsLibUtil.unsentRequest;
14
+ } = unsentRequest;
29
15
  const STATUS_PAGE = 'https://www.githubstatus.com';
30
16
  const GITHUB_STATUS_ENDPOINT = `${STATUS_PAGE}/api/v2/components.json`;
31
17
  const GITHUB_OPERATIONAL_UNITS = ['API Requests', 'Issues, Pull Requests, Projects'];
32
- class GitHub {
18
+ export default class GitHub {
19
+ bypassWriteAccessCheckForAppTokens = false;
33
20
  constructor(config, options = {}) {
34
- var _config$backend$branc;
35
- _defineProperty(this, "lock", void 0);
36
- _defineProperty(this, "api", void 0);
37
- _defineProperty(this, "options", void 0);
38
- _defineProperty(this, "originRepo", void 0);
39
- _defineProperty(this, "isBranchConfigured", void 0);
40
- _defineProperty(this, "repo", void 0);
41
- _defineProperty(this, "openAuthoringEnabled", void 0);
42
- _defineProperty(this, "useOpenAuthoring", void 0);
43
- _defineProperty(this, "alwaysForkEnabled", void 0);
44
- _defineProperty(this, "branch", void 0);
45
- _defineProperty(this, "apiRoot", void 0);
46
- _defineProperty(this, "mediaFolder", void 0);
47
- _defineProperty(this, "previewContext", void 0);
48
- _defineProperty(this, "token", void 0);
49
- _defineProperty(this, "tokenKeyword", void 0);
50
- _defineProperty(this, "squashMerges", void 0);
51
- _defineProperty(this, "cmsLabelPrefix", void 0);
52
- _defineProperty(this, "useGraphql", void 0);
53
- _defineProperty(this, "baseUrl", void 0);
54
- _defineProperty(this, "bypassWriteAccessCheckForAppTokens", false);
55
- _defineProperty(this, "_currentUserPromise", void 0);
56
- _defineProperty(this, "_userIsOriginMaintainerPromises", void 0);
57
- _defineProperty(this, "_mediaDisplayURLSem", void 0);
58
- _defineProperty(this, "getCursorAndFiles", (files, page) => {
59
- const pageSize = 20;
60
- const count = files.length;
61
- const pageCount = Math.ceil(files.length / pageSize);
62
- const actions = [];
63
- if (page > 1) {
64
- actions.push('prev');
65
- actions.push('first');
66
- }
67
- if (page < pageCount) {
68
- actions.push('next');
69
- actions.push('last');
70
- }
71
- const cursor = _decapCmsLibUtil.Cursor.create({
72
- actions,
73
- meta: {
74
- page,
75
- count,
76
- pageSize,
77
- pageCount
78
- },
79
- data: {
80
- files
81
- }
82
- });
83
- const pageFiles = files.slice((page - 1) * pageSize, page * pageSize);
84
- return {
85
- cursor,
86
- files: pageFiles
87
- };
88
- });
89
- this.options = _objectSpread({
21
+ this.options = {
90
22
  proxied: false,
91
23
  API: null,
92
- initialWorkflowStatus: ''
93
- }, options);
24
+ initialWorkflowStatus: '',
25
+ ...options
26
+ };
94
27
  if (!this.options.proxied && (config.backend.repo === null || config.backend.repo === undefined)) {
95
28
  throw new Error('The GitHub backend needs a "repo" in the backend configuration.');
96
29
  }
@@ -106,7 +39,7 @@ class GitHub {
106
39
  this.repo = this.originRepo = config.backend.repo || '';
107
40
  }
108
41
  this.alwaysForkEnabled = config.backend.always_fork || false;
109
- this.branch = ((_config$backend$branc = config.backend.branch) === null || _config$backend$branc === void 0 ? void 0 : _config$backend$branc.trim()) || 'master';
42
+ this.branch = config.backend.branch?.trim() || 'master';
110
43
  this.apiRoot = config.backend.api_root || 'https://api.github.com';
111
44
  this.token = '';
112
45
  this.tokenKeyword = 'token';
@@ -116,7 +49,7 @@ class GitHub {
116
49
  this.useGraphql = config.backend.use_graphql || false;
117
50
  this.mediaFolder = config.media_folder;
118
51
  this.previewContext = config.backend.preview_context || '';
119
- this.lock = (0, _decapCmsLibUtil.asyncLock)();
52
+ this.lock = asyncLock();
120
53
  }
121
54
  isGitBackend() {
122
55
  return true;
@@ -131,13 +64,12 @@ class GitHub {
131
64
  let auth = false;
132
65
  // no need to check auth if api is down
133
66
  if (api) {
134
- var _this$api, _this$token;
135
- auth = (await ((_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.getUser({
136
- token: (_this$token = this.token) !== null && _this$token !== void 0 ? _this$token : ''
67
+ auth = (await this.api?.getUser({
68
+ token: this.token ?? ''
137
69
  }).then(user => !!user).catch(e => {
138
70
  console.warn('Failed getting GitHub user', e);
139
71
  return false;
140
- }))) || false;
72
+ })) || false;
141
73
  }
142
74
  return {
143
75
  auth: {
@@ -150,7 +82,7 @@ class GitHub {
150
82
  };
151
83
  }
152
84
  authComponent() {
153
- const wrappedAuthenticationPage = props => (0, _react2.jsx)(_AuthenticationPage.default, _extends({}, props, {
85
+ const wrappedAuthenticationPage = props => ___EmotionJSX(AuthenticationPage, _extends({}, props, {
154
86
  backend: this
155
87
  }));
156
88
  wrappedAuthenticationPage.displayName = 'AuthenticationPage';
@@ -310,7 +242,7 @@ class GitHub {
310
242
  this.branch = repoInfo.default_branch;
311
243
  }
312
244
  }
313
- const apiCtor = this.useGraphql ? _GraphQLAPI.default : _API.default;
245
+ const apiCtor = this.useGraphql ? GraphQLAPI : API;
314
246
  this.api = new apiCtor({
315
247
  token: this.token,
316
248
  tokenKeyword: this.tokenKeyword,
@@ -327,7 +259,7 @@ class GitHub {
327
259
  });
328
260
  const user = await this.api.user();
329
261
  const isCollab = await this.api.hasWriteAccess().catch(error => {
330
- error.message = (0, _commonTags.stripIndent)`
262
+ error.message = stripIndent`
331
263
  Repo "${this.repo}" not found.
332
264
 
333
265
  Please ensure the repo information is spelled correctly.
@@ -352,10 +284,11 @@ class GitHub {
352
284
  // }
353
285
 
354
286
  // Authorized user
355
- return _objectSpread(_objectSpread({}, user), {}, {
287
+ return {
288
+ ...user,
356
289
  token: state.token,
357
290
  useOpenAuthoring: this.useOpenAuthoring
358
- });
291
+ };
359
292
  }
360
293
  logout() {
361
294
  this.token = null;
@@ -366,6 +299,37 @@ class GitHub {
366
299
  getToken() {
367
300
  return Promise.resolve(this.token);
368
301
  }
302
+ getCursorAndFiles = (files, page) => {
303
+ const pageSize = 20;
304
+ const count = files.length;
305
+ const pageCount = Math.ceil(files.length / pageSize);
306
+ const actions = [];
307
+ if (page > 1) {
308
+ actions.push('prev');
309
+ actions.push('first');
310
+ }
311
+ if (page < pageCount) {
312
+ actions.push('next');
313
+ actions.push('last');
314
+ }
315
+ const cursor = Cursor.create({
316
+ actions,
317
+ meta: {
318
+ page,
319
+ count,
320
+ pageSize,
321
+ pageCount
322
+ },
323
+ data: {
324
+ files
325
+ }
326
+ });
327
+ const pageFiles = files.slice((page - 1) * pageSize, page * pageSize);
328
+ return {
329
+ cursor,
330
+ files: pageFiles
331
+ };
332
+ };
369
333
  async entriesByFolder(folder, extension, depth) {
370
334
  const repoURL = this.api.originRepoURL;
371
335
  let cursor;
@@ -373,7 +337,7 @@ class GitHub {
373
337
  repoURL,
374
338
  depth
375
339
  }).then(files => {
376
- const filtered = files.filter(file => (0, _decapCmsLibUtil.filterByExtension)(file, extension));
340
+ const filtered = files.filter(file => filterByExtension(file, extension));
377
341
  const result = this.getCursorAndFiles(filtered, 1);
378
342
  cursor = result.cursor;
379
343
  return result.files;
@@ -381,10 +345,10 @@ class GitHub {
381
345
  const readFile = (path, id) => this.api.readFile(path, id, {
382
346
  repoURL
383
347
  });
384
- const files = await (0, _decapCmsLibUtil.entriesByFolder)(listFiles, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
348
+ const files = await entriesByFolder(listFiles, readFile, this.api.readFileMetadata.bind(this.api), API_NAME);
385
349
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
386
350
  // @ts-ignore
387
- files[_decapCmsLibUtil.CURSOR_COMPATIBILITY_SYMBOL] = cursor;
351
+ files[CURSOR_COMPATIBILITY_SYMBOL] = cursor;
388
352
  return files;
389
353
  }
390
354
  async allEntriesByFolder(folder, extension, depth, pathRegex) {
@@ -392,13 +356,13 @@ class GitHub {
392
356
  const listFiles = () => this.api.listFiles(folder, {
393
357
  repoURL,
394
358
  depth
395
- }).then(files => files.filter(file => (!pathRegex || pathRegex.test(file.path)) && (0, _decapCmsLibUtil.filterByExtension)(file, extension)));
359
+ }).then(files => files.filter(file => (!pathRegex || pathRegex.test(file.path)) && filterByExtension(file, extension)));
396
360
  const readFile = (path, id) => {
397
361
  return this.api.readFile(path, id, {
398
362
  repoURL
399
363
  });
400
364
  };
401
- const files = await (0, _decapCmsLibUtil.entriesByFolder)(listFiles, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
365
+ const files = await entriesByFolder(listFiles, readFile, this.api.readFileMetadata.bind(this.api), API_NAME);
402
366
  return files;
403
367
  }
404
368
  entriesByFiles(files) {
@@ -406,7 +370,7 @@ class GitHub {
406
370
  const readFile = (path, id) => this.api.readFile(path, id, {
407
371
  repoURL
408
372
  }).catch(() => '');
409
- return (0, _decapCmsLibUtil.entriesByFiles)(files, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
373
+ return entriesByFiles(files, readFile, this.api.readFileMetadata.bind(this.api), API_NAME);
410
374
  }
411
375
 
412
376
  // Fetches a single entry.
@@ -450,11 +414,11 @@ class GitHub {
450
414
  }));
451
415
  }
452
416
  async getMediaFile(path) {
453
- const blob = await (0, _decapCmsLibUtil.getMediaAsBlob)(path, null, this.api.readFile.bind(this.api));
454
- const name = (0, _decapCmsLibUtil.basename)(path);
455
- const fileObj = (0, _decapCmsLibUtil.blobToFileObj)(name, blob);
417
+ const blob = await getMediaAsBlob(path, null, this.api.readFile.bind(this.api));
418
+ const name = basename(path);
419
+ const fileObj = blobToFileObj(name, blob);
456
420
  const url = URL.createObjectURL(fileObj);
457
- const id = await (0, _decapCmsLibUtil.getBlobSHA)(blob);
421
+ const id = await getBlobSHA(blob);
458
422
  return {
459
423
  id,
460
424
  displayURL: url,
@@ -466,12 +430,12 @@ class GitHub {
466
430
  };
467
431
  }
468
432
  getMediaDisplayURL(displayURL) {
469
- this._mediaDisplayURLSem = this._mediaDisplayURLSem || (0, _semaphore.default)(MAX_CONCURRENT_DOWNLOADS);
470
- return (0, _decapCmsLibUtil.getMediaDisplayURL)(displayURL, this.api.readFile.bind(this.api), this._mediaDisplayURLSem);
433
+ this._mediaDisplayURLSem = this._mediaDisplayURLSem || semaphore(MAX_CONCURRENT_DOWNLOADS);
434
+ return getMediaDisplayURL(displayURL, this.api.readFile.bind(this.api), this._mediaDisplayURLSem);
471
435
  }
472
436
  persistEntry(entry, options) {
473
437
  // persistEntry is a transactional operation
474
- return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.persistFiles(entry.dataFiles, entry.assets, options), 'Failed to acquire persist entry lock');
438
+ return runWithLock(this.lock, () => this.api.persistFiles(entry.dataFiles, entry.assets, options), 'Failed to acquire persist entry lock');
475
439
  }
476
440
  async persistMedia(mediaFile, options) {
477
441
  try {
@@ -487,7 +451,7 @@ class GitHub {
487
451
  name: fileObj.name,
488
452
  size: fileObj.size,
489
453
  displayURL,
490
- path: (0, _trimStart.default)(path, '/')
454
+ path: trimStart(path, '/')
491
455
  };
492
456
  } catch (error) {
493
457
  console.error(error);
@@ -531,7 +495,7 @@ class GitHub {
531
495
  const readFile = (path, id) => this.api.readFile(path, id, {
532
496
  repoURL: this.api.originRepoURL
533
497
  }).catch(() => '');
534
- const entries = await (0, _decapCmsLibUtil.entriesByFiles)(result.files, readFile, this.api.readFileMetadata.bind(this.api), _API.API_NAME);
498
+ const entries = await entriesByFiles(result.files, readFile, this.api.readFileMetadata.bind(this.api), API_NAME);
535
499
  return {
536
500
  entries,
537
501
  cursor: result.cursor
@@ -544,9 +508,9 @@ class GitHub {
544
508
  branch,
545
509
  parseText
546
510
  });
547
- const blob = await (0, _decapCmsLibUtil.getMediaAsBlob)(file.path, file.id, readFile);
548
- const name = (0, _decapCmsLibUtil.basename)(file.path);
549
- const fileObj = (0, _decapCmsLibUtil.blobToFileObj)(name, blob);
511
+ const blob = await getMediaAsBlob(file.path, file.id, readFile);
512
+ const name = basename(file.path);
513
+ const fileObj = blobToFileObj(name, blob);
550
514
  return {
551
515
  id: file.id,
552
516
  displayURL: URL.createObjectURL(fileObj),
@@ -557,8 +521,8 @@ class GitHub {
557
521
  };
558
522
  }
559
523
  async unpublishedEntries() {
560
- const listEntriesKeys = () => this.api.listUnpublishedBranches().then(branches => branches.map(branch => (0, _decapCmsLibUtil.contentKeyFromBranch)(branch)));
561
- const ids = await (0, _decapCmsLibUtil.unpublishedEntries)(listEntriesKeys);
524
+ const listEntriesKeys = () => this.api.listUnpublishedBranches().then(branches => branches.map(branch => contentKeyFromBranch(branch)));
525
+ const ids = await unpublishedEntries(listEntriesKeys);
562
526
  return ids;
563
527
  }
564
528
  async unpublishedEntry({
@@ -579,7 +543,7 @@ class GitHub {
579
543
  }
580
544
  getBranch(collection, slug) {
581
545
  const contentKey = this.api.generateContentKey(collection, slug);
582
- const branch = (0, _decapCmsLibUtil.branchFromContentKey)(contentKey);
546
+ const branch = branchFromContentKey(contentKey);
583
547
  return branch;
584
548
  }
585
549
  async unpublishedEntryDataFile(collection, slug, path, id) {
@@ -600,7 +564,7 @@ class GitHub {
600
564
  async getDeployPreview(collection, slug) {
601
565
  try {
602
566
  const statuses = await this.api.getStatuses(collection, slug);
603
- const deployStatus = (0, _decapCmsLibUtil.getPreviewStatus)(statuses, this.previewContext);
567
+ const deployStatus = getPreviewStatus(statuses, this.previewContext);
604
568
  if (deployStatus) {
605
569
  const {
606
570
  target_url: url,
@@ -619,15 +583,14 @@ class GitHub {
619
583
  }
620
584
  updateUnpublishedEntryStatus(collection, slug, newStatus) {
621
585
  // updateUnpublishedEntryStatus is a transactional operation
622
- return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.updateUnpublishedEntryStatus(collection, slug, newStatus), 'Failed to acquire update entry status lock');
586
+ return runWithLock(this.lock, () => this.api.updateUnpublishedEntryStatus(collection, slug, newStatus), 'Failed to acquire update entry status lock');
623
587
  }
624
588
  deleteUnpublishedEntry(collection, slug) {
625
589
  // deleteUnpublishedEntry is a transactional operation
626
- return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.deleteUnpublishedEntry(collection, slug), 'Failed to acquire delete entry lock');
590
+ return runWithLock(this.lock, () => this.api.deleteUnpublishedEntry(collection, slug), 'Failed to acquire delete entry lock');
627
591
  }
628
592
  publishUnpublishedEntry(collection, slug) {
629
593
  // publishUnpublishedEntry is a transactional operation
630
- return (0, _decapCmsLibUtil.runWithLock)(this.lock, () => this.api.publishUnpublishedEntry(collection, slug), 'Failed to acquire publish entry lock');
594
+ return runWithLock(this.lock, () => this.api.publishUnpublishedEntry(collection, slug), 'Failed to acquire publish entry lock');
631
595
  }
632
- }
633
- exports.default = GitHub;
596
+ }
package/dist/esm/index.js CHANGED
@@ -1,33 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "API", {
7
- enumerable: true,
8
- get: function () {
9
- return _API.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "AuthenticationPage", {
13
- enumerable: true,
14
- get: function () {
15
- return _AuthenticationPage.default;
16
- }
17
- });
18
- exports.DecapCmsBackendGithub = void 0;
19
- Object.defineProperty(exports, "GitHubBackend", {
20
- enumerable: true,
21
- get: function () {
22
- return _implementation.default;
23
- }
24
- });
25
- var _implementation = _interopRequireDefault(require("./implementation"));
26
- var _API = _interopRequireDefault(require("./API"));
27
- var _AuthenticationPage = _interopRequireDefault(require("./AuthenticationPage"));
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
- const DecapCmsBackendGithub = exports.DecapCmsBackendGithub = {
30
- GitHubBackend: _implementation.default,
31
- API: _API.default,
32
- AuthenticationPage: _AuthenticationPage.default
33
- };
1
+ import GitHubBackend from './implementation';
2
+ import API from './API';
3
+ import AuthenticationPage from './AuthenticationPage';
4
+ export const DecapCmsBackendGithub = {
5
+ GitHubBackend,
6
+ API,
7
+ AuthenticationPage
8
+ };
9
+ export { GitHubBackend, API, AuthenticationPage };
@@ -1,15 +1,8 @@
1
- "use strict";
1
+ import { gql } from 'graphql-tag';
2
+ import * as fragments from './fragments';
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.updateBranch = exports.reopenPullRequest = exports.deleteBranch = exports.createPullRequest = exports.createBranchAndPullRequest = exports.createBranch = exports.closePullRequestAndDeleteBranch = exports.closePullRequest = void 0;
7
- var _graphqlTag = require("graphql-tag");
8
- var fragments = _interopRequireWildcard(require("./fragments"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
4
  // updateRef only works for branches at the moment
12
- const updateBranch = exports.updateBranch = (0, _graphqlTag.gql)`
5
+ export const updateBranch = gql`
13
6
  mutation updateRef($input: UpdateRefInput!) {
14
7
  updateRef(input: $input) {
15
8
  branch: ref {
@@ -26,7 +19,7 @@ deleteRef(input: $deleteRefInput) {
26
19
  clientMutationId
27
20
  }
28
21
  `;
29
- const deleteBranch = exports.deleteBranch = (0, _graphqlTag.gql)`
22
+ export const deleteBranch = gql`
30
23
  mutation deleteRef($deleteRefInput: DeleteRefInput!) {
31
24
  ${deleteRefMutationPart}
32
25
  }
@@ -39,13 +32,13 @@ closePullRequest(input: $closePullRequestInput) {
39
32
  }
40
33
  }
41
34
  `;
42
- const closePullRequest = exports.closePullRequest = (0, _graphqlTag.gql)`
35
+ export const closePullRequest = gql`
43
36
  mutation closePullRequestAndDeleteBranch($closePullRequestInput: ClosePullRequestInput!) {
44
37
  ${closePullRequestMutationPart}
45
38
  }
46
39
  ${fragments.pullRequest}
47
40
  `;
48
- const closePullRequestAndDeleteBranch = exports.closePullRequestAndDeleteBranch = (0, _graphqlTag.gql)`
41
+ export const closePullRequestAndDeleteBranch = gql`
49
42
  mutation closePullRequestAndDeleteBranch(
50
43
  $closePullRequestInput: ClosePullRequestInput!
51
44
  $deleteRefInput: DeleteRefInput!
@@ -63,13 +56,13 @@ const createPullRequestMutationPart = `
63
56
  }
64
57
  }
65
58
  `;
66
- const createPullRequest = exports.createPullRequest = (0, _graphqlTag.gql)`
59
+ export const createPullRequest = gql`
67
60
  mutation createPullRequest($createPullRequestInput: CreatePullRequestInput!) {
68
61
  ${createPullRequestMutationPart}
69
62
  }
70
63
  ${fragments.pullRequest}
71
64
  `;
72
- const createBranch = exports.createBranch = (0, _graphqlTag.gql)`
65
+ export const createBranch = gql`
73
66
  mutation createBranch($createRefInput: CreateRefInput!) {
74
67
  createRef(input: $createRefInput) {
75
68
  branch: ref {
@@ -81,7 +74,7 @@ const createBranch = exports.createBranch = (0, _graphqlTag.gql)`
81
74
  `;
82
75
 
83
76
  // createRef only works for branches at the moment
84
- const createBranchAndPullRequest = exports.createBranchAndPullRequest = (0, _graphqlTag.gql)`
77
+ export const createBranchAndPullRequest = gql`
85
78
  mutation createBranchAndPullRequest(
86
79
  $createRefInput: CreateRefInput!
87
80
  $createPullRequestInput: CreatePullRequestInput!
@@ -96,7 +89,7 @@ const createBranchAndPullRequest = exports.createBranchAndPullRequest = (0, _gra
96
89
  ${fragments.branch}
97
90
  ${fragments.pullRequest}
98
91
  `;
99
- const reopenPullRequest = exports.reopenPullRequest = (0, _graphqlTag.gql)`
92
+ export const reopenPullRequest = gql`
100
93
  mutation reopenPullRequest($reopenPullRequestInput: ReopenPullRequestInput!) {
101
94
  reopenPullRequest(input: $reopenPullRequestInput) {
102
95
  clientMutationId
@@ -1,17 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fileSha = exports.branch = exports.blob = void 0;
7
- exports.files = files;
8
- exports.user = exports.statues = exports.repository = exports.repoPermission = exports.pullRequests = exports.pullRequestAndBranch = exports.pullRequest = exports.openAuthoringBranches = void 0;
9
- var _graphqlTag = require("graphql-tag");
10
- var _commonTags = require("common-tags");
11
- var fragments = _interopRequireWildcard(require("./fragments"));
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- const repoPermission = exports.repoPermission = (0, _graphqlTag.gql)`
1
+ import { gql } from 'graphql-tag';
2
+ import { oneLine } from 'common-tags';
3
+ import * as fragments from './fragments';
4
+ export const repoPermission = gql`
15
5
  query repoPermission($owner: String!, $name: String!) {
16
6
  repository(owner: $owner, name: $name) {
17
7
  ...RepositoryParts
@@ -20,7 +10,7 @@ const repoPermission = exports.repoPermission = (0, _graphqlTag.gql)`
20
10
  }
21
11
  ${fragments.repository}
22
12
  `;
23
- const user = exports.user = (0, _graphqlTag.gql)`
13
+ export const user = gql`
24
14
  query {
25
15
  viewer {
26
16
  id
@@ -30,7 +20,7 @@ const user = exports.user = (0, _graphqlTag.gql)`
30
20
  }
31
21
  }
32
22
  `;
33
- const blob = exports.blob = (0, _graphqlTag.gql)`
23
+ export const blob = gql`
34
24
  query blob($owner: String!, $name: String!, $expression: String!) {
35
25
  repository(owner: $owner, name: $name) {
36
26
  ...RepositoryParts
@@ -44,7 +34,7 @@ const blob = exports.blob = (0, _graphqlTag.gql)`
44
34
  ${fragments.repository}
45
35
  ${fragments.blobWithText}
46
36
  `;
47
- const statues = exports.statues = (0, _graphqlTag.gql)`
37
+ export const statues = gql`
48
38
  query statues($owner: String!, $name: String!, $sha: GitObjectID!) {
49
39
  repository(owner: $owner, name: $name) {
50
40
  ...RepositoryParts
@@ -69,7 +59,7 @@ const statues = exports.statues = (0, _graphqlTag.gql)`
69
59
  `;
70
60
  function buildFilesQuery(depth = 1) {
71
61
  const PLACE_HOLDER = 'PLACE_HOLDER';
72
- let query = (0, _commonTags.oneLine)`
62
+ let query = oneLine`
73
63
  ...ObjectParts
74
64
  ... on Tree {
75
65
  entries {
@@ -79,7 +69,7 @@ function buildFilesQuery(depth = 1) {
79
69
  }
80
70
  `;
81
71
  for (let i = 0; i < depth - 1; i++) {
82
- query = query.replace(PLACE_HOLDER, (0, _commonTags.oneLine)`
72
+ query = query.replace(PLACE_HOLDER, oneLine`
83
73
  object {
84
74
  ... on Tree {
85
75
  entries {
@@ -93,8 +83,8 @@ function buildFilesQuery(depth = 1) {
93
83
  query = query.replace(PLACE_HOLDER, '');
94
84
  return query;
95
85
  }
96
- function files(depth) {
97
- return (0, _graphqlTag.gql)`
86
+ export function files(depth) {
87
+ return gql`
98
88
  query files($owner: String!, $name: String!, $expression: String!) {
99
89
  repository(owner: $owner, name: $name) {
100
90
  ...RepositoryParts
@@ -113,7 +103,7 @@ branch: ref(qualifiedName: $qualifiedName) {
113
103
  ...BranchParts
114
104
  }
115
105
  `;
116
- const branch = exports.branch = (0, _graphqlTag.gql)`
106
+ export const branch = gql`
117
107
  query branch($owner: String!, $name: String!, $qualifiedName: String!) {
118
108
  repository(owner: $owner, name: $name) {
119
109
  ...RepositoryParts
@@ -123,7 +113,7 @@ const branch = exports.branch = (0, _graphqlTag.gql)`
123
113
  ${fragments.repository}
124
114
  ${fragments.branch}
125
115
  `;
126
- const openAuthoringBranches = exports.openAuthoringBranches = (0, _graphqlTag.gql)`
116
+ export const openAuthoringBranches = gql`
127
117
  query openAuthoringBranches($owner: String!, $name: String!, $refPrefix: String!) {
128
118
  repository(owner: $owner, name: $name) {
129
119
  ...RepositoryParts
@@ -137,7 +127,7 @@ const openAuthoringBranches = exports.openAuthoringBranches = (0, _graphqlTag.gq
137
127
  ${fragments.repository}
138
128
  ${fragments.branch}
139
129
  `;
140
- const repository = exports.repository = (0, _graphqlTag.gql)`
130
+ export const repository = gql`
141
131
  query repository($owner: String!, $name: String!) {
142
132
  repository(owner: $owner, name: $name) {
143
133
  ...RepositoryParts
@@ -150,7 +140,7 @@ pullRequest(number: $number) {
150
140
  ...PullRequestParts
151
141
  }
152
142
  `;
153
- const pullRequest = exports.pullRequest = (0, _graphqlTag.gql)`
143
+ export const pullRequest = gql`
154
144
  query pullRequest($owner: String!, $name: String!, $number: Int!) {
155
145
  repository(owner: $owner, name: $name) {
156
146
  id
@@ -159,7 +149,7 @@ const pullRequest = exports.pullRequest = (0, _graphqlTag.gql)`
159
149
  }
160
150
  ${fragments.pullRequest}
161
151
  `;
162
- const pullRequests = exports.pullRequests = (0, _graphqlTag.gql)`
152
+ export const pullRequests = gql`
163
153
  query pullRequests($owner: String!, $name: String!, $head: String, $states: [PullRequestState!]) {
164
154
  repository(owner: $owner, name: $name) {
165
155
  id
@@ -172,7 +162,7 @@ const pullRequests = exports.pullRequests = (0, _graphqlTag.gql)`
172
162
  }
173
163
  ${fragments.pullRequest}
174
164
  `;
175
- const pullRequestAndBranch = exports.pullRequestAndBranch = (0, _graphqlTag.gql)`
165
+ export const pullRequestAndBranch = gql`
176
166
  query pullRequestAndBranch($owner: String!, $name: String!, $originRepoOwner: String!, $originRepoName: String!, $qualifiedName: String!, $number: Int!) {
177
167
  repository(owner: $owner, name: $name) {
178
168
  ...RepositoryParts
@@ -187,7 +177,7 @@ const pullRequestAndBranch = exports.pullRequestAndBranch = (0, _graphqlTag.gql)
187
177
  ${fragments.branch}
188
178
  ${fragments.pullRequest}
189
179
  `;
190
- const fileSha = exports.fileSha = (0, _graphqlTag.gql)`
180
+ export const fileSha = gql`
191
181
  query fileSha($owner: String!, $name: String!, $expression: String!) {
192
182
  repository(owner: $owner, name: $name) {
193
183
  ...RepositoryParts
@@ -1 +0,0 @@
1
- "use strict";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "decap-cms-backend-github",
3
3
  "description": "GitHub backend for Decap CMS",
4
- "version": "3.2.3-beta.0",
4
+ "version": "3.3.0",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-github",
7
7
  "bugs": "https://github.com/decaporg/decap-cms/issues",
@@ -38,7 +38,7 @@
38
38
  "decap-cms-ui-default": "^3.0.0",
39
39
  "lodash": "^4.17.11",
40
40
  "prop-types": "^15.7.2",
41
- "react": "17.x || 18.x"
41
+ "react": "^19.1.0"
42
42
  },
43
- "gitHead": "0f91300093c3c074f50c7af8f20a4ad331806e62"
43
+ "gitHead": "ed7e99318007b83f4c57f3237bf92b931676820a"
44
44
  }