tinacms 0.68.4 → 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,19 @@
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
+
3
17
  ## 0.68.4
4
18
 
5
19
  ### 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
  }
package/dist/client.es.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import fetchPonyfill from "fetch-ponyfill";
2
2
  const { fetch, Headers } = fetchPonyfill();
3
3
  class TinaClient {
4
- constructor({ token, url }) {
4
+ constructor({ token, url, queries }) {
5
5
  this.apiUrl = url;
6
6
  this.readonlyToken = token;
7
+ if (queries) {
8
+ this.queries = queries(this);
9
+ }
7
10
  }
8
11
  async request(args) {
9
12
  const headers = new Headers();
@@ -33,8 +36,8 @@ class TinaClient {
33
36
  };
34
37
  }
35
38
  }
36
- const createClient = (args) => {
39
+ function createClient(args) {
37
40
  const client = new TinaClient(args);
38
41
  return client;
39
- };
42
+ }
40
43
  export { TinaClient, createClient };
package/dist/client.js CHANGED
@@ -8,9 +8,12 @@
8
8
  var fetchPonyfill__default = /* @__PURE__ */ _interopDefaultLegacy(fetchPonyfill);
9
9
  const { fetch, Headers } = fetchPonyfill__default["default"]();
10
10
  class TinaClient {
11
- constructor({ token, url }) {
11
+ constructor({ token, url, queries }) {
12
12
  this.apiUrl = url;
13
13
  this.readonlyToken = token;
14
+ if (queries) {
15
+ this.queries = queries(this);
16
+ }
14
17
  }
15
18
  async request(args) {
16
19
  const headers = new Headers();
@@ -40,10 +43,10 @@
40
43
  };
41
44
  }
42
45
  }
43
- const createClient = (args) => {
46
+ function createClient(args) {
44
47
  const client = new TinaClient(args);
45
48
  return client;
46
- };
49
+ }
47
50
  exports2.TinaClient = TinaClient;
48
51
  exports2.createClient = createClient;
49
52
  Object.defineProperty(exports2, "__esModule", { value: true });
package/dist/index.es.js CHANGED
@@ -2423,6 +2423,7 @@ class TinaAdminApi {
2423
2423
  constructor(cms) {
2424
2424
  this.api = cms.api.tina;
2425
2425
  this.schema = cms.api.tina.schema;
2426
+ this.useDataLayer = cms.flags.get("experimentalData");
2426
2427
  }
2427
2428
  async isAuthenticated() {
2428
2429
  return await this.api.isAuthenticated();
@@ -2449,19 +2450,22 @@ class TinaAdminApi {
2449
2450
  }
2450
2451
  async fetchCollection(collectionName, includeDocuments) {
2451
2452
  if (includeDocuments === true) {
2452
- const response = await this.api.request(`#graphql
2453
- 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){
2454
2457
  collection(collection: $collection){
2455
2458
  name
2456
2459
  label
2457
2460
  format
2458
2461
  templates
2459
- documents @include(if: $includeDocuments) {
2462
+ documents(sort: $sort) @include(if: $includeDocuments) {
2460
2463
  totalCount
2461
2464
  edges {
2462
2465
  node {
2463
2466
  ... on Document {
2464
2467
  _sys {
2468
+ title
2465
2469
  template
2466
2470
  breadcrumbs
2467
2471
  path
@@ -2475,8 +2479,39 @@ class TinaAdminApi {
2475
2479
  }
2476
2480
  }
2477
2481
  }
2478
- }`, { variables: { collection: collectionName, includeDocuments } });
2479
- 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
+ }
2480
2515
  } else {
2481
2516
  try {
2482
2517
  const collection = this.schema.getCollection(collectionName);
@@ -3746,6 +3781,8 @@ const CollectionListPage = () => {
3746
3781
  }, /* @__PURE__ */ React.createElement("tbody", {
3747
3782
  className: "divide-y divide-gray-150"
3748
3783
  }, documents.map((document) => {
3784
+ var _a2;
3785
+ const hasTitle = Boolean(document.node._sys.title);
3749
3786
  const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
3750
3787
  return /* @__PURE__ */ React.createElement("tr", {
3751
3788
  key: `document-${document.node._sys.relativePath}`,
@@ -3761,11 +3798,17 @@ const CollectionListPage = () => {
3761
3798
  className: "inline-block h-6 w-auto opacity-70"
3762
3799
  }), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("span", {
3763
3800
  className: "block text-xs text-gray-400 mb-1 uppercase"
3764
- }, "Filename"), /* @__PURE__ */ React.createElement("span", {
3801
+ }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React.createElement("span", {
3765
3802
  className: "h-5 leading-5 block whitespace-nowrap"
3766
3803
  }, subfolders && /* @__PURE__ */ React.createElement("span", {
3767
3804
  className: "text-xs text-gray-400"
3768
- }, `${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", {
3769
3812
  className: "px-6 py-4 whitespace-nowrap"
3770
3813
  }, /* @__PURE__ */ React.createElement("span", {
3771
3814
  className: "block text-xs text-gray-400 mb-1 uppercase"
package/dist/index.js CHANGED
@@ -2442,6 +2442,7 @@ mutation addPendingDocumentMutation(
2442
2442
  constructor(cms) {
2443
2443
  this.api = cms.api.tina;
2444
2444
  this.schema = cms.api.tina.schema;
2445
+ this.useDataLayer = cms.flags.get("experimentalData");
2445
2446
  }
2446
2447
  async isAuthenticated() {
2447
2448
  return await this.api.isAuthenticated();
@@ -2468,19 +2469,22 @@ mutation addPendingDocumentMutation(
2468
2469
  }
2469
2470
  async fetchCollection(collectionName, includeDocuments) {
2470
2471
  if (includeDocuments === true) {
2471
- const response = await this.api.request(`#graphql
2472
- 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){
2473
2476
  collection(collection: $collection){
2474
2477
  name
2475
2478
  label
2476
2479
  format
2477
2480
  templates
2478
- documents @include(if: $includeDocuments) {
2481
+ documents(sort: $sort) @include(if: $includeDocuments) {
2479
2482
  totalCount
2480
2483
  edges {
2481
2484
  node {
2482
2485
  ... on Document {
2483
2486
  _sys {
2487
+ title
2484
2488
  template
2485
2489
  breadcrumbs
2486
2490
  path
@@ -2494,8 +2498,39 @@ mutation addPendingDocumentMutation(
2494
2498
  }
2495
2499
  }
2496
2500
  }
2497
- }`, { variables: { collection: collectionName, includeDocuments } });
2498
- 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
+ }
2499
2534
  } else {
2500
2535
  try {
2501
2536
  const collection = this.schema.getCollection(collectionName);
@@ -3765,6 +3800,8 @@ This will work when developing locally but NOT when deployed to production.
3765
3800
  }, /* @__PURE__ */ React__default["default"].createElement("tbody", {
3766
3801
  className: "divide-y divide-gray-150"
3767
3802
  }, documents.map((document) => {
3803
+ var _a2;
3804
+ const hasTitle = Boolean(document.node._sys.title);
3768
3805
  const subfolders = document.node._sys.breadcrumbs.slice(0, -1).join("/");
3769
3806
  return /* @__PURE__ */ React__default["default"].createElement("tr", {
3770
3807
  key: `document-${document.node._sys.relativePath}`,
@@ -3780,11 +3817,17 @@ This will work when developing locally but NOT when deployed to production.
3780
3817
  className: "inline-block h-6 w-auto opacity-70"
3781
3818
  }), /* @__PURE__ */ React__default["default"].createElement("span", null, /* @__PURE__ */ React__default["default"].createElement("span", {
3782
3819
  className: "block text-xs text-gray-400 mb-1 uppercase"
3783
- }, "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
3820
+ }, hasTitle ? "Title" : "Filename"), /* @__PURE__ */ React__default["default"].createElement("span", {
3784
3821
  className: "h-5 leading-5 block whitespace-nowrap"
3785
3822
  }, subfolders && /* @__PURE__ */ React__default["default"].createElement("span", {
3786
3823
  className: "text-xs text-gray-400"
3787
- }, `${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", {
3788
3831
  className: "px-6 py-4 whitespace-nowrap"
3789
3832
  }, /* @__PURE__ */ React__default["default"].createElement("span", {
3790
3833
  className: "block text-xs text-gray-400 mb-1 uppercase"
@@ -53,7 +53,7 @@ declare type APIProviderProps = {
53
53
  * The API url From this client will be used to make requests.
54
54
  *
55
55
  */
56
- client: TinaClient;
56
+ client: TinaClient<unknown>;
57
57
  /**
58
58
  * Content API URL
59
59
  *
@@ -10,21 +10,26 @@ 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 interface TinaClientArs {
13
+ export interface TinaClientArgs<GenQueries = Record<string, unknown>> {
14
14
  url: string;
15
15
  token?: string;
16
+ queries?: (client: TinaClient<GenQueries>) => GenQueries;
16
17
  }
17
18
  export declare type TinaClientRequestArgs = {
18
19
  variables?: Record<string, any>;
19
20
  query: string;
20
- } & Partial<TinaClientArs>;
21
- export declare class TinaClient {
21
+ } & Partial<Omit<TinaClientArgs, 'queries'>>;
22
+ export declare class TinaClient<GenQueries> {
22
23
  apiUrl: string;
23
24
  readonlyToken?: string;
24
- constructor({ token, url }: TinaClientArs);
25
+ /**
26
+ *
27
+ */
28
+ queries?: GenQueries;
29
+ constructor({ token, url, queries }: TinaClientArgs<GenQueries>);
25
30
  request<DataType extends Record<string, any> = any>(args: TinaClientRequestArgs): Promise<{
26
31
  data: DataType;
27
32
  query: string;
28
33
  }>;
29
34
  }
30
- export declare const createClient: (args: TinaClientArs) => TinaClient;
35
+ export declare function createClient<GenQueries>(args: TinaClientArgs<GenQueries>): TinaClient<GenQueries>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.68.4",
3
+ "version": "0.68.5",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"
@@ -25,9 +25,9 @@
25
25
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
26
26
  "@headlessui/react": "^1.5.0",
27
27
  "@heroicons/react": "^1.0.4",
28
- "@tinacms/schema-tools": "0.0.3",
28
+ "@tinacms/schema-tools": "0.0.4",
29
29
  "@tinacms/sharedctx": "0.1.1",
30
- "@tinacms/toolkit": "0.56.27",
30
+ "@tinacms/toolkit": "0.56.28",
31
31
  "crypto-js": "^4.0.0",
32
32
  "fetch-ponyfill": "^7.1.0",
33
33
  "final-form": "4.20.1",