tinacms 0.68.2 → 0.68.5

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,41 @@
1
1
  # tinacms
2
2
 
3
+ ## 0.68.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 646cad8da: Adds support for using the generated client on the frontend
8
+ - f857616f6: Rename sdk to queries
9
+ - 6e2ed31a2: Added `isTitle` property to the schema that allows the title to be displayed in the CMS
10
+ - Updated dependencies [a196198bd]
11
+ - Updated dependencies [57a4a3789]
12
+ - Updated dependencies [6e2ed31a2]
13
+ - Updated dependencies [ba1499029]
14
+ - @tinacms/toolkit@0.56.28
15
+ - @tinacms/schema-tools@0.0.4
16
+
17
+ ## 0.68.4
18
+
19
+ ### Patch Changes
20
+
21
+ - 7372f90ca: Adds a new client that can be used on the backend and frontend.
22
+ - Updated dependencies [d4f98d0fc]
23
+ - Updated dependencies [7e2272442]
24
+ - @tinacms/toolkit@0.56.27
25
+
26
+ ## 0.68.3
27
+
28
+ ### Patch Changes
29
+
30
+ - 8b7ee346a: - Display label instead of name for mdx dropdown af306fa
31
+ - Fix issue where reset triggered chagnes to the wrong rich-text field 03f6191
32
+ - Fix issue where null children in a code block threw an error e454bce
33
+ - Updated dependencies [f6f56bcc0]
34
+ - Updated dependencies [59d33a74a]
35
+ - Updated dependencies [8b7ee346a]
36
+ - Updated dependencies [acb38bf9f]
37
+ - @tinacms/toolkit@0.56.26
38
+
3
39
  ## 0.68.2
4
40
 
5
41
  ### Patch Changes
@@ -11,15 +11,13 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import type { TinaCMS } from '@tinacms/toolkit';
14
+ import type { TinaSchema } from '@tinacms/schema-tools';
15
+ import type { Client } from '../internalClient';
14
16
  import type { Collection, DocumentForm } from './types';
15
17
  export declare class TinaAdminApi {
16
- api: {
17
- request: (query: string, { variables }: {
18
- variables: object;
19
- }) => any;
20
- isAuthenticated: () => boolean;
21
- };
22
- schema: any;
18
+ api: Client;
19
+ useDataLayer: boolean;
20
+ schema: TinaSchema;
23
21
  constructor(cms: TinaCMS);
24
22
  isAuthenticated(): Promise<boolean>;
25
23
  fetchCollections(): Promise<Collection[]>;
@@ -31,6 +29,6 @@ export declare class TinaAdminApi {
31
29
  fetchDocument(collectionName: string, relativePath: string): Promise<{
32
30
  document: DocumentForm;
33
31
  }>;
34
- createDocument(collectionName: string, relativePath: string, params: Object): Promise<any>;
35
- updateDocument(collectionName: string, relativePath: string, params: Object): Promise<any>;
32
+ createDocument(collectionName: string, relativePath: string, params: Object): Promise<unknown>;
33
+ updateDocument(collectionName: string, relativePath: string, params: Object): Promise<unknown>;
36
34
  }
@@ -25,6 +25,7 @@ export interface DocumentNode {
25
25
  relativePath: string;
26
26
  filename: string;
27
27
  extension: string;
28
+ title?: string;
28
29
  };
29
30
  };
30
31
  }
@@ -12,7 +12,7 @@ limitations under the License.
12
12
  */
13
13
  import React from 'react';
14
14
  import { TinaCMS, MediaStore } from '@tinacms/toolkit';
15
- import { Client, TinaIOConfig } from '../client';
15
+ import { Client, TinaIOConfig } from '../internalClient';
16
16
  import { CreateClientProps } from '../utils';
17
17
  export interface TinaCloudMediaStoreClass {
18
18
  new (client: Client): MediaStore;
@@ -0,0 +1,13 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ export * from './unifiedClient';
@@ -0,0 +1,43 @@
1
+ import fetchPonyfill from "fetch-ponyfill";
2
+ const { fetch, Headers } = fetchPonyfill();
3
+ class TinaClient {
4
+ constructor({ token, url, queries }) {
5
+ this.apiUrl = url;
6
+ this.readonlyToken = token;
7
+ if (queries) {
8
+ this.queries = queries(this);
9
+ }
10
+ }
11
+ async request(args) {
12
+ const headers = new Headers();
13
+ if (this.readonlyToken) {
14
+ headers.append("X-API-KEY", this.readonlyToken);
15
+ }
16
+ headers.append("Content-Type", "application/json");
17
+ const bodyString = JSON.stringify({
18
+ query: args.query,
19
+ variables: (args == null ? void 0 : args.variables) || {}
20
+ });
21
+ const url = (args == null ? void 0 : args.url) || this.apiUrl;
22
+ const res = await fetch(url, {
23
+ method: "POST",
24
+ headers,
25
+ body: bodyString,
26
+ redirect: "follow"
27
+ });
28
+ const json = await res.json();
29
+ if (json.errors) {
30
+ throw new Error(`Unable to fetch, errors:
31
+ ${json.errors.map((error) => error.message).join("\n")}`);
32
+ }
33
+ return {
34
+ data: json == null ? void 0 : json.data,
35
+ query: args.query
36
+ };
37
+ }
38
+ }
39
+ function createClient(args) {
40
+ const client = new TinaClient(args);
41
+ return client;
42
+ }
43
+ export { TinaClient, createClient };
package/dist/client.js ADDED
@@ -0,0 +1,54 @@
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) {
4
+ "use strict";
5
+ function _interopDefaultLegacy(e) {
6
+ return e && typeof e === "object" && "default" in e ? e : { "default": e };
7
+ }
8
+ var fetchPonyfill__default = /* @__PURE__ */ _interopDefaultLegacy(fetchPonyfill);
9
+ const { fetch, Headers } = fetchPonyfill__default["default"]();
10
+ class TinaClient {
11
+ constructor({ token, url, queries }) {
12
+ this.apiUrl = url;
13
+ this.readonlyToken = token;
14
+ if (queries) {
15
+ this.queries = queries(this);
16
+ }
17
+ }
18
+ async request(args) {
19
+ const headers = new Headers();
20
+ if (this.readonlyToken) {
21
+ headers.append("X-API-KEY", this.readonlyToken);
22
+ }
23
+ headers.append("Content-Type", "application/json");
24
+ const bodyString = JSON.stringify({
25
+ query: args.query,
26
+ variables: (args == null ? void 0 : args.variables) || {}
27
+ });
28
+ const url = (args == null ? void 0 : args.url) || this.apiUrl;
29
+ const res = await fetch(url, {
30
+ method: "POST",
31
+ headers,
32
+ body: bodyString,
33
+ redirect: "follow"
34
+ });
35
+ const json = await res.json();
36
+ if (json.errors) {
37
+ throw new Error(`Unable to fetch, errors:
38
+ ${json.errors.map((error) => error.message).join("\n")}`);
39
+ }
40
+ return {
41
+ data: json == null ? void 0 : json.data,
42
+ query: args.query
43
+ };
44
+ }
45
+ }
46
+ function createClient(args) {
47
+ const client = new TinaClient(args);
48
+ return client;
49
+ }
50
+ exports2.TinaClient = TinaClient;
51
+ exports2.createClient = createClient;
52
+ Object.defineProperty(exports2, "__esModule", { value: true });
53
+ exports2[Symbol.toStringTag] = "Module";
54
+ });
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- export * from './client';
13
+ export * from './internalClient';
14
14
  export * from './auth';
15
15
  export * from './utils';
16
16
  export * from './tina-cms';
package/dist/index.es.js CHANGED
@@ -1605,16 +1605,11 @@ function reducer(state, action) {
1605
1605
  const blueprint = getFormNodeBlueprint(formNode, state);
1606
1606
  if (blueprint.hasValuesField) {
1607
1607
  changeSets.push(__spreadValues({
1608
- path: [formNodePath(formNode), "values"].join(".")
1609
- }, buildChangeSet(event, formNode)));
1610
- }
1611
- if (blueprint.hasDataJSONField) {
1612
- changeSets.push(__spreadValues({
1613
- path: [formNodePath(formNode), "dataJSON"].join(".")
1608
+ path: [formNodePath(formNode), "_values"].join(".")
1614
1609
  }, buildChangeSet(event, formNode)));
1615
1610
  }
1616
1611
  changeSets.push(__spreadValues({
1617
- path: [formNodePath(formNode), "data"].join(".")
1612
+ path: [formNodePath(formNode)].join(".")
1618
1613
  }, buildChangeSet(event, formNode)));
1619
1614
  });
1620
1615
  return __spreadProps(__spreadValues({}, state), { changeSets });
@@ -2428,6 +2423,7 @@ class TinaAdminApi {
2428
2423
  constructor(cms) {
2429
2424
  this.api = cms.api.tina;
2430
2425
  this.schema = cms.api.tina.schema;
2426
+ this.useDataLayer = cms.flags.get("experimentalData");
2431
2427
  }
2432
2428
  async isAuthenticated() {
2433
2429
  return await this.api.isAuthenticated();
@@ -2454,19 +2450,22 @@ class TinaAdminApi {
2454
2450
  }
2455
2451
  async fetchCollection(collectionName, includeDocuments) {
2456
2452
  if (includeDocuments === true) {
2457
- const response = await this.api.request(`#graphql
2458
- query($collection: String!, $includeDocuments: Boolean!){
2453
+ if (this.useDataLayer) {
2454
+ const sort = this.schema.getIsTitleFieldName(collectionName);
2455
+ const response = await this.api.request(`#graphql
2456
+ query($collection: String!, $includeDocuments: Boolean!, $sort: String){
2459
2457
  collection(collection: $collection){
2460
2458
  name
2461
2459
  label
2462
2460
  format
2463
2461
  templates
2464
- documents @include(if: $includeDocuments) {
2462
+ documents(sort: $sort) @include(if: $includeDocuments) {
2465
2463
  totalCount
2466
2464
  edges {
2467
2465
  node {
2468
2466
  ... on Document {
2469
2467
  _sys {
2468
+ title
2470
2469
  template
2471
2470
  breadcrumbs
2472
2471
  path
@@ -2480,8 +2479,39 @@ class TinaAdminApi {
2480
2479
  }
2481
2480
  }
2482
2481
  }
2483
- }`, { variables: { collection: collectionName, includeDocuments } });
2484
- return response.collection;
2482
+ }`, { variables: { collection: collectionName, includeDocuments, sort } });
2483
+ return response.collection;
2484
+ } else {
2485
+ const response = await this.api.request(`#graphql
2486
+ query($collection: String!, $includeDocuments: Boolean!){
2487
+ collection(collection: $collection){
2488
+ name
2489
+ label
2490
+ format
2491
+ templates
2492
+ documents @include(if: $includeDocuments) {
2493
+ totalCount
2494
+ edges {
2495
+ node {
2496
+ ... on Document {
2497
+ _sys {
2498
+ # TODO: only include title if we need to
2499
+ template
2500
+ breadcrumbs
2501
+ path
2502
+ basename
2503
+ relativePath
2504
+ filename
2505
+ extension
2506
+ }
2507
+ }
2508
+ }
2509
+ }
2510
+ }
2511
+ }
2512
+ }`, { variables: { collection: collectionName, includeDocuments } });
2513
+ return response.collection;
2514
+ }
2485
2515
  } else {
2486
2516
  try {
2487
2517
  const collection = this.schema.getCollection(collectionName);
@@ -2985,11 +3015,13 @@ const TinaCMSProvider2 = (_c) => {
2985
3015
  "formifyCallback",
2986
3016
  "schema"
2987
3017
  ]);
3018
+ var _a;
2988
3019
  const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
2989
- if (!props.apiURL && !validOldSetup) {
2990
- throw new Error(`apiURL is a required field`);
3020
+ const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
3021
+ if (!apiURL && !validOldSetup) {
3022
+ throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
2991
3023
  }
2992
- const { branch, clientId, isLocalClient } = props.apiURL ? parseURL(props.apiURL) : {
3024
+ const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
2993
3025
  branch: props.branch,
2994
3026
  clientId: props.clientId,
2995
3027
  isLocalClient: props.isLocalClient
@@ -3749,6 +3781,8 @@ const CollectionListPage = () => {
3749
3781
  }, /* @__PURE__ */ React.createElement("tbody", {
3750
3782
  className: "divide-y divide-gray-150"
3751
3783
  }, documents.map((document) => {
3784
+ var _a2;
3785
+ const hasTitle = Boolean(document.node._sys.title);
3752
3786
  const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
3753
3787
  return /* @__PURE__ */ React.createElement("tr", {
3754
3788
  key: `document-${document.node._sys.relativePath}`,
@@ -3764,11 +3798,17 @@ const CollectionListPage = () => {
3764
3798
  className: "inline-block h-6 w-auto opacity-70"
3765
3799
  }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
3766
3800
  className: "block text-xs text-gray-400 mb-1 uppercase"
3767
- }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3801
+ }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React.createElement("span", {
3768
3802
  className: "h-5 leading-5 block whitespace-nowrap"
3769
3803
  }, subfolders && /* @__PURE__ */ React.createElement("span", {
3770
3804
  className: "text-xs text-gray-400"
3771
- }, `${subfolders}/`), /* @__PURE__ */ React.createElement("span", null, document.node._sys.filename))))), /* @__PURE__ */ React.createElement("td", {
3805
+ }, `${subfolders}/`), /* @__PURE__ */ React.createElement("span", null, hasTitle ? (_a2 = document.node._sys) == null ? void 0 : _a2.title : document.node._sys.filename))))), hasTitle && /* @__PURE__ */ React.createElement("td", {
3806
+ className: "px-6 py-4 whitespace-nowrap"
3807
+ }, /* @__PURE__ */ React.createElement("span", {
3808
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3809
+ }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3810
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3811
+ }, document.node._sys.filename)), /* @__PURE__ */ React.createElement("td", {
3772
3812
  className: "px-6 py-4 whitespace-nowrap"
3773
3813
  }, /* @__PURE__ */ React.createElement("span", {
3774
3814
  className: "block text-xs text-gray-400 mb-1 uppercase"
package/dist/index.js CHANGED
@@ -1624,16 +1624,11 @@ var __objRest = (source, exclude) => {
1624
1624
  const blueprint = getFormNodeBlueprint(formNode, state);
1625
1625
  if (blueprint.hasValuesField) {
1626
1626
  changeSets.push(__spreadValues({
1627
- path: [formNodePath(formNode), "values"].join(".")
1628
- }, buildChangeSet(event, formNode)));
1629
- }
1630
- if (blueprint.hasDataJSONField) {
1631
- changeSets.push(__spreadValues({
1632
- path: [formNodePath(formNode), "dataJSON"].join(".")
1627
+ path: [formNodePath(formNode), "_values"].join(".")
1633
1628
  }, buildChangeSet(event, formNode)));
1634
1629
  }
1635
1630
  changeSets.push(__spreadValues({
1636
- path: [formNodePath(formNode), "data"].join(".")
1631
+ path: [formNodePath(formNode)].join(".")
1637
1632
  }, buildChangeSet(event, formNode)));
1638
1633
  });
1639
1634
  return __spreadProps(__spreadValues({}, state), { changeSets });
@@ -2447,6 +2442,7 @@ mutation addPendingDocumentMutation(
2447
2442
  constructor(cms) {
2448
2443
  this.api = cms.api.tina;
2449
2444
  this.schema = cms.api.tina.schema;
2445
+ this.useDataLayer = cms.flags.get("experimentalData");
2450
2446
  }
2451
2447
  async isAuthenticated() {
2452
2448
  return await this.api.isAuthenticated();
@@ -2473,19 +2469,22 @@ mutation addPendingDocumentMutation(
2473
2469
  }
2474
2470
  async fetchCollection(collectionName, includeDocuments) {
2475
2471
  if (includeDocuments === true) {
2476
- const response = await this.api.request(`#graphql
2477
- query($collection: String!, $includeDocuments: Boolean!){
2472
+ if (this.useDataLayer) {
2473
+ const sort = this.schema.getIsTitleFieldName(collectionName);
2474
+ const response = await this.api.request(`#graphql
2475
+ query($collection: String!, $includeDocuments: Boolean!, $sort: String){
2478
2476
  collection(collection: $collection){
2479
2477
  name
2480
2478
  label
2481
2479
  format
2482
2480
  templates
2483
- documents @include(if: $includeDocuments) {
2481
+ documents(sort: $sort) @include(if: $includeDocuments) {
2484
2482
  totalCount
2485
2483
  edges {
2486
2484
  node {
2487
2485
  ... on Document {
2488
2486
  _sys {
2487
+ title
2489
2488
  template
2490
2489
  breadcrumbs
2491
2490
  path
@@ -2499,8 +2498,39 @@ mutation addPendingDocumentMutation(
2499
2498
  }
2500
2499
  }
2501
2500
  }
2502
- }`, { variables: { collection: collectionName, includeDocuments } });
2503
- return response.collection;
2501
+ }`, { variables: { collection: collectionName, includeDocuments, sort } });
2502
+ return response.collection;
2503
+ } else {
2504
+ const response = await this.api.request(`#graphql
2505
+ query($collection: String!, $includeDocuments: Boolean!){
2506
+ collection(collection: $collection){
2507
+ name
2508
+ label
2509
+ format
2510
+ templates
2511
+ documents @include(if: $includeDocuments) {
2512
+ totalCount
2513
+ edges {
2514
+ node {
2515
+ ... on Document {
2516
+ _sys {
2517
+ # TODO: only include title if we need to
2518
+ template
2519
+ breadcrumbs
2520
+ path
2521
+ basename
2522
+ relativePath
2523
+ filename
2524
+ extension
2525
+ }
2526
+ }
2527
+ }
2528
+ }
2529
+ }
2530
+ }
2531
+ }`, { variables: { collection: collectionName, includeDocuments } });
2532
+ return response.collection;
2533
+ }
2504
2534
  } else {
2505
2535
  try {
2506
2536
  const collection = this.schema.getCollection(collectionName);
@@ -3004,11 +3034,13 @@ mutation addPendingDocumentMutation(
3004
3034
  "formifyCallback",
3005
3035
  "schema"
3006
3036
  ]);
3037
+ var _a;
3007
3038
  const validOldSetup = new Boolean(props == null ? void 0 : props.isLocalClient) || new Boolean(props == null ? void 0 : props.clientId) && new Boolean(props == null ? void 0 : props.branch);
3008
- if (!props.apiURL && !validOldSetup) {
3009
- throw new Error(`apiURL is a required field`);
3039
+ const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
3040
+ if (!apiURL && !validOldSetup) {
3041
+ throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
3010
3042
  }
3011
- const { branch, clientId, isLocalClient } = props.apiURL ? parseURL(props.apiURL) : {
3043
+ const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
3012
3044
  branch: props.branch,
3013
3045
  clientId: props.clientId,
3014
3046
  isLocalClient: props.isLocalClient
@@ -3768,6 +3800,8 @@ This will work when developing locally but NOT when deployed to production.
3768
3800
  }, /* @__PURE__ */ React__default["default"].createElement("tbody", {
3769
3801
  className: "divide-y divide-gray-150"
3770
3802
  }, documents.map((document) => {
3803
+ var _a2;
3804
+ const hasTitle = Boolean(document.node._sys.title);
3771
3805
  const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
3772
3806
  return /* @__PURE__ */ React__default["default"].createElement("tr", {
3773
3807
  key: `document-${document.node._sys.relativePath}`,
@@ -3783,11 +3817,17 @@ This will work when developing locally but NOT when deployed to production.
3783
3817
  className: "inline-block h-6 w-auto opacity-70"
3784
3818
  }), /* @__PURE__ */ React__default["default"].createElement("span", null, /* @__PURE__ */ React__default["default"].createElement("span", {
3785
3819
  className: "block text-xs text-gray-400 mb-1 uppercase"
3786
- }, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
3820
+ }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
3787
3821
  className: "h-5 leading-5 block whitespace-nowrap"
3788
3822
  }, subfolders && /* @__PURE__ */ React__default["default"].createElement("span", {
3789
3823
  className: "text-xs text-gray-400"
3790
- }, `${subfolders}/`), /* @__PURE__ */ React__default["default"].createElement("span", null, document.node._sys.filename))))), /* @__PURE__ */ React__default["default"].createElement("td", {
3824
+ }, `${subfolders}/`), /* @__PURE__ */ React__default["default"].createElement("span", null, hasTitle ? (_a2 = document.node._sys) == null ? void 0 : _a2.title : document.node._sys.filename))))), hasTitle && /* @__PURE__ */ React__default["default"].createElement("td", {
3825
+ className: "px-6 py-4 whitespace-nowrap"
3826
+ }, /* @__PURE__ */ React__default["default"].createElement("span", {
3827
+ className: "block text-xs text-gray-400 mb-1 uppercase"
3828
+ }, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
3829
+ className: "h-5 leading-5 block text-sm font-medium text-gray-900"
3830
+ }, document.node._sys.filename)), /* @__PURE__ */ React__default["default"].createElement("td", {
3791
3831
  className: "px-6 py-4 whitespace-nowrap"
3792
3832
  }, /* @__PURE__ */ React__default["default"].createElement("span", {
3793
3833
  className: "block text-xs text-gray-400 mb-1 uppercase"
File without changes
File without changes
@@ -108,7 +108,7 @@ const TinaMarkdown = ({
108
108
  case "code_block":
109
109
  const value = child.children.map((item) => {
110
110
  var _a2;
111
- return ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "";
111
+ return item.children ? ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "" : "";
112
112
  }).join("\n");
113
113
  if (components[child.type]) {
114
114
  const Component2 = components[child.type];
package/dist/rich-text.js CHANGED
@@ -115,7 +115,7 @@ var __objRest = (source, exclude) => {
115
115
  case "code_block":
116
116
  const value = child.children.map((item) => {
117
117
  var _a2;
118
- return ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "";
118
+ return item.children ? ((_a2 = item.children[0]) == null ? void 0 : _a2.text) || "" : "";
119
119
  }).join("\n");
120
120
  if (components[child.type]) {
121
121
  const Component2 = components[child.type];
@@ -11,13 +11,19 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import React from 'react';
14
+ import type { TinaClient } from './client';
14
15
  import { TinaCloudMediaStoreClass } from './auth';
15
16
  import type { TinaCMS } from '@tinacms/toolkit';
16
17
  import type { TinaCloudSchema } from '@tinacms/schema-tools';
17
- import type { TinaIOConfig } from './client/index';
18
+ import type { TinaIOConfig } from './internalClient/index';
18
19
  import type { formifyCallback } from './hooks/use-graphql-forms';
19
20
  import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
20
21
  declare type APIProviderProps = {
22
+ /**
23
+ * The API url From this client will be used to make requests.
24
+ *
25
+ */
26
+ client?: never;
21
27
  /**
22
28
  * Content API URL
23
29
  *
@@ -42,6 +48,36 @@ declare type APIProviderProps = {
42
48
  * @deprecated use apiURL instead
43
49
  */
44
50
  clientId?: never;
51
+ } | {
52
+ /**
53
+ * The API url From this client will be used to make requests.
54
+ *
55
+ */
56
+ client: TinaClient<unknown>;
57
+ /**
58
+ * Content API URL
59
+ *
60
+ */
61
+ apiURL?: never;
62
+ /**
63
+ * Point to the local version of GraphQL instead of tina.io
64
+ * https://tina.io/docs/tinacms-context/#adding-tina-to-the-sites-frontend
65
+ *
66
+ * @deprecated use apiURL instead
67
+ */
68
+ isLocalClient?: never;
69
+ /**
70
+ * The base branch to pull content from. Note that this is ignored for local development
71
+ *
72
+ * @deprecated use apiURL instead
73
+ */
74
+ branch?: never;
75
+ /**
76
+ * Your clientID from tina.aio
77
+ *
78
+ * @deprecated use apiURL instead
79
+ */
80
+ clientId?: never;
45
81
  } | {
46
82
  /**
47
83
  * Content API URL
@@ -67,6 +103,11 @@ declare type APIProviderProps = {
67
103
  * @deprecated use apiURL instead
68
104
  */
69
105
  clientId?: string;
106
+ /**
107
+ * The API url From this client will be used to make requests.
108
+ *
109
+ */
110
+ client: never;
70
111
  };
71
112
  interface BaseProviderProps {
72
113
  /** Callback if you need access to the TinaCMS instance */
@@ -0,0 +1,35 @@
1
+ /**
2
+ Copyright 2021 Forestry.io Holdings, Inc.
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
12
+ */
13
+ export interface TinaClientArgs<GenQueries = Record<string, unknown>> {
14
+ url: string;
15
+ token?: string;
16
+ queries?: (client: TinaClient<GenQueries>) => GenQueries;
17
+ }
18
+ export declare type TinaClientRequestArgs = {
19
+ variables?: Record<string, any>;
20
+ query: string;
21
+ } & Partial<Omit<TinaClientArgs, 'queries'>>;
22
+ export declare class TinaClient<GenQueries> {
23
+ apiUrl: string;
24
+ readonlyToken?: string;
25
+ /**
26
+ *
27
+ */
28
+ queries?: GenQueries;
29
+ constructor({ token, url, queries }: TinaClientArgs<GenQueries>);
30
+ request<DataType extends Record<string, any> = any>(args: TinaClientRequestArgs): Promise<{
31
+ data: DataType;
32
+ query: string;
33
+ }>;
34
+ }
35
+ export declare function createClient<GenQueries>(args: TinaClientArgs<GenQueries>): TinaClient<GenQueries>;
@@ -10,8 +10,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- import { Client } from '../client';
14
- import type { TinaIOConfig } from '../client';
13
+ import { Client } from '../internalClient';
14
+ import type { TinaIOConfig } from '../internalClient';
15
15
  import * as yup from 'yup';
16
16
  import { TinaCloudSchema } from '@tinacms/schema-tools';
17
17
  export interface CreateClientProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.68.2",
3
+ "version": "0.68.5",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -9,7 +9,8 @@
9
9
  "entryPoints": [
10
10
  "src/index.ts",
11
11
  "src/edit-state.tsx",
12
- "src/rich-text.tsx"
12
+ "src/rich-text.tsx",
13
+ "src/client.ts"
13
14
  ]
14
15
  },
15
16
  "typings": "dist/index.d.ts",
@@ -24,10 +25,11 @@
24
25
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
25
26
  "@headlessui/react": "^1.5.0",
26
27
  "@heroicons/react": "^1.0.4",
27
- "@tinacms/schema-tools": "0.0.3",
28
+ "@tinacms/schema-tools": "0.0.4",
28
29
  "@tinacms/sharedctx": "0.1.1",
29
- "@tinacms/toolkit": "0.56.25",
30
+ "@tinacms/toolkit": "0.56.28",
30
31
  "crypto-js": "^4.0.0",
32
+ "fetch-ponyfill": "^7.1.0",
31
33
  "final-form": "4.20.1",
32
34
  "graphql": "^15.1.0",
33
35
  "graphql-tag": "^2.11.0",