tinacms 1.2.1 → 1.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,11 +1,8 @@
1
- /**
2
-
3
- */
4
1
  import { TokenObject } from '../auth/authenticate';
5
2
  import { BranchData, EventBus } from '@tinacms/toolkit';
6
3
  import { DocumentNode, GraphQLSchema } from 'graphql';
7
4
  import gql from 'graphql-tag';
8
- import { TinaSchema, TinaCloudSchema } from '@tinacms/schema-tools';
5
+ import { TinaSchema, Schema } from '@tinacms/schema-tools';
9
6
  export declare type OnLoginFunc = (args: {
10
7
  token: TokenObject;
11
8
  }) => Promise<void>;
@@ -16,7 +13,7 @@ export declare type TinaIOConfig = {
16
13
  contentApiUrlOverride?: string;
17
14
  };
18
15
  interface ServerOptions {
19
- schema?: TinaCloudSchema<false>;
16
+ schema?: Schema;
20
17
  clientId: string;
21
18
  branch: string;
22
19
  customContentApiUrl?: string;
@@ -24,6 +21,90 @@ interface ServerOptions {
24
21
  tinaioConfig?: TinaIOConfig;
25
22
  tokenStorage?: 'MEMORY' | 'LOCAL_STORAGE' | 'CUSTOM';
26
23
  }
24
+ /**
25
+ * The function you pass to `asyncPoll` should return a promise
26
+ * that resolves with object that satisfies this interface.
27
+ *
28
+ * The `done` property indicates to the async poller whether to
29
+ * continue polling or not.
30
+ *
31
+ * When done is `true` that means you've got what you need
32
+ * and the poller will resolve with `data`.
33
+ *
34
+ * When done is `false` taht means you don't have what you need
35
+ * and the poller will continue polling.
36
+ */
37
+ export interface AsyncData<T> {
38
+ done: boolean;
39
+ data?: T;
40
+ }
41
+ /**
42
+ * Your custom function you provide to the async poller should
43
+ * satisfy this interface. Your function returns a promise that
44
+ * resolves with `AsyncData` to indicate to the poller whether
45
+ * you have what you need or we should continue polling.
46
+ */
47
+ export interface AsyncFunction<T> extends Function {
48
+ (): PromiseLike<AsyncData<T>>;
49
+ }
50
+ /**
51
+ * How to repeatedly call an async function until get a desired result.
52
+ *
53
+ * Inspired by the following gist:
54
+ * https://gist.github.com/twmbx/2321921670c7e95f6fad164fbdf3170e#gistcomment-3053587
55
+ * https://davidwalsh.name/javascript-polling
56
+ *
57
+ * Usage:
58
+ asyncPoll(
59
+ async (): Promise<AsyncData<any>> => {
60
+ try {
61
+ const result = await getYourAsyncResult();
62
+ if (result.isWhatYouWant) {
63
+ return Promise.resolve({
64
+ done: true,
65
+ data: result,
66
+ });
67
+ } else {
68
+ return Promise.resolve({
69
+ done: false
70
+ });
71
+ }
72
+ } catch (err) {
73
+ return Promise.reject(err);
74
+ }
75
+ },
76
+ 500, // interval
77
+ 15000, // timeout
78
+ );
79
+ */
80
+ export declare function asyncPoll<T>(
81
+ /**
82
+ * Function to call periodically until it resolves or rejects.
83
+ *
84
+ * It should resolve as soon as possible indicating if it found
85
+ * what it was looking for or not. If not then it will be reinvoked
86
+ * after the `pollInterval` if we haven't timed out.
87
+ *
88
+ * Rejections will stop the polling and be propagated.
89
+ */
90
+ fn: AsyncFunction<T>,
91
+ /**
92
+ * Milliseconds to wait before attempting to resolve the promise again.
93
+ * The promise won't be called concurrently. This is the wait period
94
+ * after the promise has resolved/rejected before trying again for a
95
+ * successful resolve so long as we haven't timed out.
96
+ *
97
+ * Default 5 seconds.
98
+ */
99
+ pollInterval?: number,
100
+ /**
101
+ * Max time to keep polling to receive a successful resolved response.
102
+ * If the promise never resolves before the timeout then this method
103
+ * rejects with a timeout error.
104
+ *
105
+ * Default 30 seconds.
106
+ */
107
+ pollTimeout?: number): Promise<T>;
27
108
  export declare class Client {
28
109
  onLogin?: OnLoginFunc;
29
110
  onLogout?: () => Promise<void>;
@@ -74,10 +155,6 @@ export declare class Client {
74
155
  * }
75
156
  */
76
157
  getOptimizedQuery: (documentNode: DocumentNode) => Promise<DocumentNode>;
77
- requestWithForm<ReturnType>(query: (gqlTag: typeof gql) => DocumentNode, { variables, useUnstableFormify, }: {
78
- variables: any;
79
- useUnstableFormify?: boolean;
80
- }): Promise<ReturnType>;
81
158
  request<ReturnType>(query: ((gqlTag: typeof gql) => DocumentNode) | string, { variables }: {
82
159
  variables: object;
83
160
  }): Promise<ReturnType>;
@@ -121,14 +198,34 @@ export declare class Client {
121
198
  delinquencyDate: number;
122
199
  billingState: 'current' | 'late' | 'delinquent';
123
200
  }>;
124
- listBranches(): Promise<any>;
201
+ waitForIndexStatus({ ref }: {
202
+ ref: string;
203
+ }): Promise<any>;
204
+ getIndexStatus({ ref }: {
205
+ ref: string;
206
+ }): Promise<{
207
+ status?: "unknown" | "complete" | "failed" | "inprogress";
208
+ timestamp?: number;
209
+ }>;
210
+ listBranches(): Promise<{
211
+ indexStatus: {
212
+ status?: "unknown" | "complete" | "failed" | "inprogress";
213
+ timestamp?: number;
214
+ };
215
+ name?: string;
216
+ protected?: boolean;
217
+ commit?: {
218
+ url?: string;
219
+ sha?: string;
220
+ };
221
+ }[]>;
125
222
  createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
126
223
  }
127
224
  export declare const DEFAULT_LOCAL_TINA_GQL_SERVER_URL = "http://localhost:4001/graphql";
128
225
  export declare class LocalClient extends Client {
129
226
  constructor(props?: {
130
227
  customContentApiUrl?: string;
131
- schema?: TinaCloudSchema<false>;
228
+ schema?: Schema;
132
229
  } & Omit<ServerOptions, 'clientId' | 'branch'>);
133
230
  get isLocalMode(): boolean;
134
231
  logout(): Promise<void>;
package/dist/style.css CHANGED
@@ -375,6 +375,15 @@
375
375
  margin-left: auto;
376
376
  margin-right: auto;
377
377
  }
378
+ .tina-tailwind .mb-6 {
379
+ margin-bottom: 24px;
380
+ }
381
+ .tina-tailwind .mr-1 {
382
+ margin-right: 4px;
383
+ }
384
+ .tina-tailwind .mb-8 {
385
+ margin-bottom: 32px;
386
+ }
378
387
  .tina-tailwind .-ml-px {
379
388
  margin-left: -1px;
380
389
  }
@@ -408,18 +417,12 @@
408
417
  .tina-tailwind .mr-1\.5 {
409
418
  margin-right: 6px;
410
419
  }
411
- .tina-tailwind .mr-1 {
412
- margin-right: 4px;
413
- }
414
420
  .tina-tailwind .block {
415
421
  display: block;
416
422
  }
417
423
  .tina-tailwind .inline-block {
418
424
  display: inline-block;
419
425
  }
420
- .tina-tailwind .inline {
421
- display: inline;
422
- }
423
426
  .tina-tailwind .flex {
424
427
  display: flex;
425
428
  }
@@ -462,6 +465,12 @@
462
465
  .tina-tailwind .w-10 {
463
466
  width: 40px;
464
467
  }
468
+ .tina-tailwind .w-12 {
469
+ width: 48px;
470
+ }
471
+ .tina-tailwind .w-7 {
472
+ width: 28px;
473
+ }
465
474
  .tina-tailwind .w-auto {
466
475
  width: auto;
467
476
  }
@@ -657,6 +666,10 @@
657
666
  --tw-bg-opacity: 1;
658
667
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
659
668
  }
669
+ .tina-tailwind .bg-gray-100 {
670
+ --tw-bg-opacity: 1;
671
+ background-color: rgb(237 236 243 / var(--tw-bg-opacity));
672
+ }
660
673
  .tina-tailwind .bg-gray-50 {
661
674
  --tw-bg-opacity: 1;
662
675
  background-color: rgb(246 246 249 / var(--tw-bg-opacity));
@@ -699,6 +712,9 @@
699
712
  .tina-tailwind .to-black {
700
713
  --tw-gradient-to: #000;
701
714
  }
715
+ .tina-tailwind .fill-current {
716
+ fill: currentColor;
717
+ }
702
718
  .tina-tailwind .px-4 {
703
719
  padding-left: 16px;
704
720
  padding-right: 16px;
@@ -793,14 +809,18 @@
793
809
  font-size: 16px;
794
810
  line-height: 1.5;
795
811
  }
796
- .tina-tailwind .text-sm {
797
- font-size: 14px;
798
- line-height: 1.43;
812
+ .tina-tailwind .text-4xl {
813
+ font-size: 36px;
814
+ line-height: 1.1;
799
815
  }
800
816
  .tina-tailwind .text-xl {
801
817
  font-size: 20px;
802
818
  line-height: 1.4;
803
819
  }
820
+ .tina-tailwind .text-sm {
821
+ font-size: 14px;
822
+ line-height: 1.43;
823
+ }
804
824
  .tina-tailwind .text-md {
805
825
  font-size: 16px;
806
826
  line-height: 1.5;
@@ -841,6 +861,14 @@
841
861
  --tw-text-opacity: 1;
842
862
  color: rgb(67 62 82 / var(--tw-text-opacity));
843
863
  }
864
+ .tina-tailwind .text-red-500 {
865
+ --tw-text-opacity: 1;
866
+ color: rgb(239 68 68 / var(--tw-text-opacity));
867
+ }
868
+ .tina-tailwind .text-red-400 {
869
+ --tw-text-opacity: 1;
870
+ color: rgb(248 113 113 / var(--tw-text-opacity));
871
+ }
844
872
  .tina-tailwind .text-blue-600 {
845
873
  --tw-text-opacity: 1;
846
874
  color: rgb(5 116 228 / var(--tw-text-opacity));
@@ -876,13 +904,12 @@
876
904
  --tw-text-opacity: 1;
877
905
  color: rgb(37 35 54 / var(--tw-text-opacity));
878
906
  }
879
- .tina-tailwind .text-red-500 {
880
- --tw-text-opacity: 1;
881
- color: rgb(239 68 68 / var(--tw-text-opacity));
882
- }
883
907
  .tina-tailwind .underline {
884
908
  text-decoration-line: underline;
885
909
  }
910
+ .tina-tailwind .opacity-70 {
911
+ opacity: .7;
912
+ }
886
913
  .tina-tailwind .opacity-100 {
887
914
  opacity: 1;
888
915
  }
@@ -901,9 +928,6 @@
901
928
  .tina-tailwind .opacity-50 {
902
929
  opacity: .5;
903
930
  }
904
- .tina-tailwind .opacity-70 {
905
- opacity: .7;
906
- }
907
931
  .tina-tailwind .shadow-lg {
908
932
  --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
909
933
  --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);
@@ -2,7 +2,6 @@
2
2
 
3
3
  */
4
4
  /// <reference types="react" />
5
- import type { formifyCallback } from './hooks/use-graphql-forms';
6
5
  import { useDocumentCreatorPlugin } from './hooks/use-content-creator';
7
6
  import { TinaCMSProviderDefaultProps } from './types/cms';
8
7
  /**
@@ -12,10 +11,6 @@ import { TinaCMSProviderDefaultProps } from './types/cms';
12
11
  */
13
12
  export declare const TinaCMSProvider2: ({ query, documentCreatorCallback, formifyCallback, schema, ...props }: TinaCMSProviderDefaultProps) => JSX.Element;
14
13
  export declare type DocumentCreatorCallback = Parameters<typeof useDocumentCreatorPlugin>[0];
15
- export declare const TinaDataProvider: ({ children, formifyCallback, }: {
16
- children: any;
17
- formifyCallback: formifyCallback;
18
- }) => JSX.Element;
19
14
  /**
20
15
  * @deprecated v0.62.0: Use `staticRequest` and a "try catch" block instead. see https://tina.io/docs/features/data-fetching/#querying-tina-content-in-nextjs for more details
21
16
  *
@@ -3,7 +3,7 @@
3
3
  */
4
4
  /// <reference types="react" />
5
5
  import type { TinaCMS } from '@tinacms/toolkit';
6
- import type { TinaCloudSchema, TinaCloudSchemaConfig } from '@tinacms/schema-tools';
6
+ import type { Schema, Config } from '@tinacms/schema-tools';
7
7
  import type { TinaCloudMediaStoreClass } from '../auth';
8
8
  import type { useDocumentCreatorPlugin } from '../hooks/use-content-creator';
9
9
  import type { formifyCallback } from '../hooks/use-graphql-forms';
@@ -30,7 +30,7 @@ interface BaseProviderProps {
30
30
  /** TinaCMS media store instance */
31
31
  mediaStore?: TinaCloudMediaStoreClass | (() => Promise<TinaCloudMediaStoreClass>);
32
32
  tinaioConfig?: TinaIOConfig;
33
- schema?: TinaCloudSchema<false>;
33
+ schema?: Schema;
34
34
  }
35
35
  declare type QueryProviderProps = {
36
36
  /** Your React page component */
@@ -51,5 +51,5 @@ declare type QueryProviderProps = {
51
51
  /** The `data` from getStaticProps */
52
52
  data?: never;
53
53
  };
54
- export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps & TinaCloudSchemaConfig;
54
+ export declare type TinaCMSProviderDefaultProps = QueryProviderProps & APIProviderProps & BaseProviderProps & Config;
55
55
  export {};
@@ -4,7 +4,7 @@
4
4
  import { Client } from '../internalClient';
5
5
  import type { TinaIOConfig } from '../internalClient';
6
6
  import * as yup from 'yup';
7
- import { TinaCloudSchema } from '@tinacms/schema-tools';
7
+ import { Schema } from '@tinacms/schema-tools';
8
8
  export interface CreateClientProps {
9
9
  clientId?: string;
10
10
  isLocalClient?: boolean;
@@ -12,7 +12,7 @@ export interface CreateClientProps {
12
12
  owner?: string;
13
13
  repo?: string;
14
14
  branch?: string;
15
- schema?: TinaCloudSchema<false>;
15
+ schema?: Schema;
16
16
  apiUrl?: string;
17
17
  }
18
18
  export declare const createClient: ({ clientId, isLocalClient, branch, tinaioConfig, schema, apiUrl, }: CreateClientProps) => Client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -51,13 +51,14 @@
51
51
  "typings": "dist/index.d.ts",
52
52
  "license": "Apache-2.0",
53
53
  "dependencies": {
54
+ "@graphql-inspector/core": "^4.0.0",
54
55
  "@graphql-tools/relay-operation-optimizer": "^6.4.1",
55
56
  "@headlessui/react": "^1.5.0",
56
57
  "@heroicons/react": "^1.0.4",
57
58
  "@react-hook/window-size": "^3.0.7",
58
- "@tinacms/schema-tools": "1.3.1",
59
+ "@tinacms/schema-tools": "1.3.3",
59
60
  "@tinacms/sharedctx": "1.0.1",
60
- "@tinacms/toolkit": "1.3.3",
61
+ "@tinacms/toolkit": "1.4.0",
61
62
  "crypto-js": "^4.0.0",
62
63
  "encoding": "0.1.13",
63
64
  "fetch-ponyfill": "^7.1.0",
@@ -68,7 +69,8 @@
68
69
  "prism-react-renderer": "^1.3.5",
69
70
  "react-icons": "^4.3.1",
70
71
  "react-router-dom": "6",
71
- "yup": "^0.32.0"
72
+ "yup": "^0.32.0",
73
+ "zod": "^3.14.3"
72
74
  },
73
75
  "devDependencies": {
74
76
  "@graphql-tools/utils": "^8.6.1",
@@ -76,7 +78,7 @@
76
78
  "@testing-library/react": "^12.0.0",
77
79
  "@testing-library/react-hooks": "^7.0.2",
78
80
  "@testing-library/user-event": "^12.7.0",
79
- "@tinacms/scripts": "1.0.2",
81
+ "@tinacms/scripts": "1.0.3",
80
82
  "@types/jest": "^27.0.1",
81
83
  "@types/lodash": "^4.14.169",
82
84
  "@types/node": "^14.0.13",
@@ -1,81 +0,0 @@
1
- /**
2
-
3
- */
4
- import * as G from 'graphql';
5
- import type { BlueprintPath } from './types';
6
- /**
7
- *
8
- * This check ensures that at type is a Document, but only one
9
- * that can be "formified". When using `Node` or `Document`, those
10
- * query fields should not have forms generated since they can't contain
11
- * fields.
12
- *
13
- * ```graphql
14
- * # Can be formified
15
- * {
16
- * getPostDocument(relativePath: "") {
17
- * data {
18
- * title
19
- * }
20
- * }
21
- * }
22
- * ```
23
- *
24
- * ```graphql
25
- * # cannot be formified, even though it is a document field
26
- * {
27
- * getPostDocument(relativePath: "") {
28
- * ...on Document {
29
- * id
30
- * }
31
- * }
32
- * }
33
- * ```
34
- */
35
- export declare const isFormifiableDocument: (t: G.GraphQLOutputType) => boolean;
36
- export declare const isScalarType: (t: G.GraphQLOutputType) => boolean;
37
- export declare const isConnectionField: (t: G.GraphQLOutputType) => boolean;
38
- /**
39
- * Selects the appropriate field from a GraphQLObject based on the selection's name
40
- */
41
- export declare const getObjectField: (object: G.GraphQLOutputType, selectionNode: G.FieldNode) => G.GraphQLField<any, any, {
42
- [key: string]: any;
43
- }>;
44
- /**
45
- * Selects the appropriate type from a union based on the selection's typeCondition
46
- *
47
- * ```graphql
48
- * post {
49
- * # would return PostDocument
50
- * ...on PostDocument { ... }
51
- * }
52
- * ```
53
- */
54
- export declare const getSelectedUnionType: (unionType: G.GraphQLOutputType, selectionNode: G.InlineFragmentNode) => any;
55
- /**
56
- * Checks if the given type is a list type. Even though
57
- * this function is built-in to GraphQL it doesn't handle
58
- * the scenario where the list type is wrapped in a non-null
59
- * type, so the extra check here is needed.
60
- */
61
- export declare function isListType(type: unknown): boolean;
62
- /**
63
- *
64
- * Throws an error if the provided type is not a GraphQLUnionType
65
- */
66
- export declare function ensureOperationDefinition(type: G.DefinitionNode): asserts type is G.OperationDefinitionNode;
67
- /**
68
- * Generates the name and alias information for a given field node
69
- * and appends it to a shallow copy of the path provided
70
- */
71
- export declare function buildPath({ fieldNode, type, parentTypename, path, }: {
72
- fieldNode: G.FieldNode;
73
- type: G.GraphQLOutputType;
74
- parentTypename?: string;
75
- path?: BlueprintPath[];
76
- }): BlueprintPath[];
77
- export declare const metaFields: G.SelectionNode[];
78
- export declare const getRelativeBlueprint: (path: BlueprintPath[]) => string;
79
- export declare const isSysField: (fieldNode: G.FieldNode) => boolean;
80
- export declare const getBlueprintId: (path: BlueprintPath[]) => string;
81
- export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
@@ -1,13 +0,0 @@
1
- /**
2
-
3
- */
4
- import * as G from 'graphql';
5
- import type { DocumentBlueprint } from './types';
6
- export declare const formify: ({ schema, query, getOptimizedQuery, }: {
7
- schema: G.GraphQLSchema;
8
- query: string;
9
- getOptimizedQuery: (query: G.DocumentNode) => Promise<G.DocumentNode>;
10
- }) => Promise<{
11
- formifiedQuery: G.DocumentNode;
12
- blueprints: DocumentBlueprint[];
13
- }>;
@@ -1,16 +0,0 @@
1
- /**
2
-
3
- */
4
- import type { TinaCMS } from '@tinacms/toolkit';
5
- import { formify } from './formify';
6
- import { onSubmitArgs } from '../use-graphql-forms';
7
- import type { OnChangeEvent, State } from './types';
8
- export { formify };
9
- export declare const useFormify: ({ query, cms, variables, onSubmit, formify: formifyFunc, eventList, }: {
10
- query?: string;
11
- cms: TinaCMS;
12
- variables: object;
13
- onSubmit?: (args: onSubmitArgs) => void;
14
- formify: any;
15
- eventList?: OnChangeEvent[];
16
- }) => State;
@@ -1,18 +0,0 @@
1
- /**
2
-
3
- */
4
- import { FormNode, State, Action, OnChangeEvent } from './types';
5
- export declare function reducer(state: State, action: Action): State;
6
- export declare const buildChangeSet: (event: OnChangeEvent, formNode: FormNode) => {
7
- fieldDefinition: {
8
- name: string;
9
- type: "string" | "object" | "reference";
10
- list?: boolean;
11
- parentTypename: string;
12
- };
13
- name: string;
14
- formId: string;
15
- mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
16
- value: unknown;
17
- formNode: FormNode;
18
- };
@@ -1,4 +0,0 @@
1
- /**
2
-
3
- */
4
- export declare const testRunner: (query: any, events: any, dirname: any, expectNoChange?: boolean) => Promise<void>;
@@ -1,3 +0,0 @@
1
- declare const schema: any;
2
- export declare const tinaConfig: import("@tinacms/schema-tools/dist/types").Config<(cms: import("@tinacms/toolkit/dist/tina-cms").TinaCMS) => import("@tinacms/toolkit/dist/tina-cms").TinaCMS, import("../../use-graphql-forms").formifyCallback, import("../../use-content-creator").DocumentCreatorArgs, undefined>;
3
- export default schema;
@@ -1,16 +0,0 @@
1
- /**
2
-
3
- */
4
- import { TinaCMS } from '@tinacms/toolkit';
5
- import 'isomorphic-fetch';
6
- /**
7
- * We're just mocking the tina api so we can mimic the real-world getSchema
8
- */
9
- declare const cms: TinaCMS;
10
- export declare const printOutput: (event: any, previous: any, after: any) => string;
11
- export { printState } from '../util';
12
- export declare function sleep(ms: any): Promise<unknown>;
13
- export { cms };
14
- export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
15
- export declare const buildFileOutput: (dirname: any) => string;
16
- export declare const buildMarkdownOutput: (dirname: any, counter: any) => string;