tinacms 0.68.6 → 0.68.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.68.7
4
+
5
+ ### Patch Changes
6
+
7
+ - aaaa5bb09: Added pagination to the CMS
8
+ - e06dbb3ca: Adds `waitForDB` cmd to cli
9
+ - Updated dependencies [aaaa5bb09]
10
+ - @tinacms/toolkit@0.56.30
11
+
3
12
  ## 0.68.6
4
13
 
5
14
  ### Patch Changes
@@ -25,7 +25,7 @@ export declare class TinaAdminApi {
25
25
  collection: string;
26
26
  relativePath: string;
27
27
  }): Promise<void>;
28
- fetchCollection(collectionName: string, includeDocuments: boolean): Promise<Collection>;
28
+ fetchCollection(collectionName: string, includeDocuments: boolean, after?: string): Promise<Collection>;
29
29
  fetchDocument(collectionName: string, relativePath: string): Promise<{
30
30
  document: DocumentForm;
31
31
  }>;
@@ -12,16 +12,17 @@ limitations under the License.
12
12
  */
13
13
  import type { TinaCMS } from '@tinacms/toolkit';
14
14
  import type { Collection } from '../types';
15
- export declare const useGetCollection: (cms: TinaCMS, collectionName: string, includeDocuments?: boolean) => {
15
+ export declare const useGetCollection: (cms: TinaCMS, collectionName: string, includeDocuments?: boolean, after?: string) => {
16
16
  collection: Collection;
17
17
  loading: boolean;
18
18
  error: Error;
19
19
  reFetchCollection: () => void;
20
20
  };
21
- declare const GetCollection: ({ cms, collectionName, includeDocuments, children, }: {
21
+ declare const GetCollection: ({ cms, collectionName, includeDocuments, startCursor, children, }: {
22
22
  cms: TinaCMS;
23
23
  collectionName: string;
24
24
  includeDocuments?: boolean;
25
+ startCursor?: string;
25
26
  children: any;
26
27
  }) => JSX.Element;
27
28
  export default GetCollection;
@@ -51,6 +51,12 @@ export interface Collection {
51
51
  templates?: Template[];
52
52
  documents?: {
53
53
  totalCount?: number;
54
+ pageInfo: {
55
+ hasPreviousPage: boolean;
56
+ hasNextPage: boolean;
57
+ startCursor?: string;
58
+ endCursor?: string;
59
+ };
54
60
  edges?: DocumentNode[];
55
61
  };
56
62
  }
package/dist/client.es.js CHANGED
@@ -1,7 +1,39 @@
1
1
  import fetchPonyfill from "fetch-ponyfill";
2
+ import UrlPattern from "url-pattern";
2
3
  const { fetch, Headers } = fetchPonyfill();
4
+ const TINA_HOST = "content.tinajs.io";
3
5
  class TinaClient {
4
6
  constructor({ token, url, queries }) {
7
+ this.parseURL = (overrideUrl) => {
8
+ const url2 = overrideUrl || this.apiUrl;
9
+ if (url2.includes("localhost")) {
10
+ return {
11
+ host: "localhost",
12
+ branch: null,
13
+ isLocalClient: true,
14
+ clientId: null
15
+ };
16
+ }
17
+ const params = new URL(url2);
18
+ const pattern = new UrlPattern("/content/:clientId/github/*", {
19
+ escapeChar: " "
20
+ });
21
+ const result = pattern.match(params.pathname);
22
+ const branch = result == null ? void 0 : result._;
23
+ const clientId = result == null ? void 0 : result.clientId;
24
+ if (!branch || !clientId) {
25
+ throw new Error(`Invalid URL format provided. Expected: https://${TINA_HOST}/content/<ClientID>/github/<Branch> but but received ${url2}`);
26
+ }
27
+ if (params.host !== TINA_HOST) {
28
+ throw new Error(`The only supported hosts are ${TINA_HOST} or localhost, but received ${params.host}.`);
29
+ }
30
+ return {
31
+ host: params.host,
32
+ clientId,
33
+ branch,
34
+ isLocalClient: false
35
+ };
36
+ };
5
37
  this.apiUrl = url;
6
38
  this.readonlyToken = token;
7
39
  if (queries) {
@@ -40,4 +72,4 @@ function createClient(args) {
40
72
  const client = new TinaClient(args);
41
73
  return client;
42
74
  }
43
- export { TinaClient, createClient };
75
+ export { TINA_HOST, TinaClient, createClient };
package/dist/client.js CHANGED
@@ -1,14 +1,46 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("fetch-ponyfill")) : typeof define === "function" && define.amd ? define(["exports", "fetch-ponyfill"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
- })(this, function(exports2, fetchPonyfill) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("fetch-ponyfill"), require("url-pattern")) : typeof define === "function" && define.amd ? define(["exports", "fetch-ponyfill", "url-pattern"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, fetchPonyfill, UrlPattern) {
4
4
  "use strict";
5
5
  function _interopDefaultLegacy(e) {
6
6
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
7
7
  }
8
8
  var fetchPonyfill__default = /* @__PURE__ */ _interopDefaultLegacy(fetchPonyfill);
9
+ var UrlPattern__default = /* @__PURE__ */ _interopDefaultLegacy(UrlPattern);
9
10
  const { fetch, Headers } = fetchPonyfill__default["default"]();
11
+ const TINA_HOST = "content.tinajs.io";
10
12
  class TinaClient {
11
13
  constructor({ token, url, queries }) {
14
+ this.parseURL = (overrideUrl) => {
15
+ const url2 = overrideUrl || this.apiUrl;
16
+ if (url2.includes("localhost")) {
17
+ return {
18
+ host: "localhost",
19
+ branch: null,
20
+ isLocalClient: true,
21
+ clientId: null
22
+ };
23
+ }
24
+ const params = new URL(url2);
25
+ const pattern = new UrlPattern__default["default"]("/content/:clientId/github/*", {
26
+ escapeChar: " "
27
+ });
28
+ const result = pattern.match(params.pathname);
29
+ const branch = result == null ? void 0 : result._;
30
+ const clientId = result == null ? void 0 : result.clientId;
31
+ if (!branch || !clientId) {
32
+ throw new Error(`Invalid URL format provided. Expected: https://${TINA_HOST}/content/<ClientID>/github/<Branch> but but received ${url2}`);
33
+ }
34
+ if (params.host !== TINA_HOST) {
35
+ throw new Error(`The only supported hosts are ${TINA_HOST} or localhost, but received ${params.host}.`);
36
+ }
37
+ return {
38
+ host: params.host,
39
+ clientId,
40
+ branch,
41
+ isLocalClient: false
42
+ };
43
+ };
12
44
  this.apiUrl = url;
13
45
  this.readonlyToken = token;
14
46
  if (queries) {
@@ -47,6 +79,7 @@
47
79
  const client = new TinaClient(args);
48
80
  return client;
49
81
  }
82
+ exports2.TINA_HOST = TINA_HOST;
50
83
  exports2.TinaClient = TinaClient;
51
84
  exports2.createClient = createClient;
52
85
  Object.defineProperty(exports2, "__esModule", { value: true });