@tinacms/schema-tools 1.2.0 → 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.
- package/LICENSE +8 -0
- package/dist/index.d.ts +2 -10
- package/dist/index.es.js +63 -3
- package/dist/index.js +66 -4
- package/dist/schema/TinaSchema.d.ts +1 -10
- package/dist/schema/addNamespaceToSchema.d.ts +1 -10
- package/dist/schema/index.d.ts +1 -10
- package/dist/schema/resolveField.d.ts +1 -10
- package/dist/schema/resolveForm.d.ts +1 -10
- package/dist/types/SchemaTypes.d.ts +1 -10
- package/dist/types/config.d.ts +1 -10
- package/dist/types/index.d.ts +0 -12
- package/dist/types/schema2.d.ts +1 -10
- package/dist/types/types2.d.ts +1 -10
- package/dist/types.d.ts +51 -12
- package/dist/util/hasDuplicates.d.ts +1 -10
- package/dist/util/index.d.ts +2 -10
- package/dist/util/lastItem.d.ts +1 -10
- package/dist/util/namer.d.ts +1 -10
- package/dist/util/parseURL.d.ts +10 -0
- package/dist/util/parseZodErrors.d.ts +1 -10
- package/dist/util/sequential.d.ts +1 -10
- package/dist/util/validate.d.ts +1 -10
- package/dist/validate/fields.d.ts +1 -10
- package/dist/validate/index.d.ts +1 -10
- package/dist/validate/properties.d.ts +1 -10
- package/dist/validate/schema.d.ts +2 -11
- package/dist/validate/tinaCloudSchemaConfig.d.ts +1 -10
- package/package.json +3 -2
package/LICENSE
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
Copyright (c) 2023-present Forestry.io Holdings Inc.
|
|
2
|
+
|
|
3
|
+
Portions of the TinaCMS software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
* All software that resides under the "packages/@tinacms/datalayer/" and the "packages/@tinacms/graphql/" directories (the "Tina Data Layer"), is licensed under the license defined in "packages/@tinacms/datalayer/LICENSE".
|
|
6
|
+
|
|
7
|
+
* All software outside of the above-mentioned directories is available under the "Apache 2.0" license as set forth below.
|
|
8
|
+
|
|
1
9
|
Apache License
|
|
2
10
|
Version 2.0, January 2004
|
|
3
11
|
http://www.apache.org/licenses/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export * from './schema';
|
|
14
5
|
export * from './types/index';
|
|
15
6
|
export * from './validate';
|
|
16
7
|
export * from './util/namer';
|
|
8
|
+
export * from './util/parseURL';
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as yup from "yup";
|
|
2
|
+
import UrlPattern from "url-pattern";
|
|
2
3
|
import z$1, { z, ZodError } from "zod";
|
|
3
4
|
function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
4
5
|
if (typeof maybeNode === "string") {
|
|
@@ -114,6 +115,50 @@ function findDuplicates(array = []) {
|
|
|
114
115
|
} else
|
|
115
116
|
return void 0;
|
|
116
117
|
}
|
|
118
|
+
const TINA_HOST = "content.tinajs.io";
|
|
119
|
+
const parseURL = (url) => {
|
|
120
|
+
if (url.startsWith("/")) {
|
|
121
|
+
return {
|
|
122
|
+
branch: null,
|
|
123
|
+
isLocalClient: false,
|
|
124
|
+
clientId: null,
|
|
125
|
+
host: null
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (url.includes("localhost")) {
|
|
129
|
+
return {
|
|
130
|
+
branch: null,
|
|
131
|
+
isLocalClient: true,
|
|
132
|
+
clientId: null,
|
|
133
|
+
host: "localhost"
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const params = new URL(url);
|
|
137
|
+
const isTinaCloud = params.host.includes("tinajs.dev") || params.host.includes("tina.io") || params.host.includes("tinajs.io");
|
|
138
|
+
if (!isTinaCloud) {
|
|
139
|
+
return {
|
|
140
|
+
branch: null,
|
|
141
|
+
isLocalClient: true,
|
|
142
|
+
clientId: null,
|
|
143
|
+
host: params.host
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const pattern = new UrlPattern("/content/:clientId/github/*", {
|
|
147
|
+
escapeChar: " "
|
|
148
|
+
});
|
|
149
|
+
const result = pattern.match(params.pathname);
|
|
150
|
+
const branch = result == null ? void 0 : result._;
|
|
151
|
+
const clientId = result == null ? void 0 : result.clientId;
|
|
152
|
+
if (!branch || !clientId) {
|
|
153
|
+
throw new Error(`Invalid URL format provided. Expected: https://content.tinajs.io/content/<ClientID>/github/<Branch> but but received ${url}`);
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
host: params.host,
|
|
157
|
+
branch,
|
|
158
|
+
clientId,
|
|
159
|
+
isLocalClient: false
|
|
160
|
+
};
|
|
161
|
+
};
|
|
117
162
|
class TinaSchema {
|
|
118
163
|
constructor(config) {
|
|
119
164
|
this.config = config;
|
|
@@ -293,7 +338,15 @@ class TinaSchema {
|
|
|
293
338
|
return { [_template]: this.transformCollectablePayload(rest, field) };
|
|
294
339
|
}
|
|
295
340
|
} else {
|
|
296
|
-
|
|
341
|
+
if (field.list) {
|
|
342
|
+
assertShape(value, (yup2) => yup2.array(yup2.object()));
|
|
343
|
+
return value.map((item) => {
|
|
344
|
+
return this.transformCollectablePayload(item, field);
|
|
345
|
+
});
|
|
346
|
+
} else {
|
|
347
|
+
assertShape(value, (yup2) => yup2.object());
|
|
348
|
+
return this.transformCollectablePayload(value, field);
|
|
349
|
+
}
|
|
297
350
|
}
|
|
298
351
|
else {
|
|
299
352
|
return value;
|
|
@@ -777,7 +830,14 @@ const Template = z.object({
|
|
|
777
830
|
});
|
|
778
831
|
const TinaCloudCollectionBase = z.object({
|
|
779
832
|
label: z.string().optional(),
|
|
780
|
-
name,
|
|
833
|
+
name: name.superRefine((val, ctx) => {
|
|
834
|
+
if (val === "relativePath") {
|
|
835
|
+
ctx.addIssue({
|
|
836
|
+
code: z.ZodIssueCode.custom,
|
|
837
|
+
message: `name cannot be 'relativePath'. 'relativePath' is a reserved field name.`
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
}),
|
|
781
841
|
format: z.enum(FORMATS).optional()
|
|
782
842
|
});
|
|
783
843
|
const TinaCloudCollection = TinaCloudCollectionBase.extend({
|
|
@@ -856,4 +916,4 @@ const validateSchema = ({
|
|
|
856
916
|
}
|
|
857
917
|
}
|
|
858
918
|
};
|
|
859
|
-
export { NAMER, TinaSchema, TinaSchemaValidationError, addNamespaceToSchema, resolveField, resolveForm, validateSchema, validateTinaCloudSchemaConfig };
|
|
919
|
+
export { NAMER, TINA_HOST, TinaSchema, TinaSchemaValidationError, addNamespaceToSchema, parseURL, resolveField, resolveForm, validateSchema, validateTinaCloudSchemaConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("yup"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "yup", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP));
|
|
3
|
-
})(this, function(exports2, yup, z) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("yup"), require("url-pattern"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "yup", "url-pattern", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP, global.NOOP));
|
|
3
|
+
})(this, function(exports2, yup, UrlPattern, z) {
|
|
4
4
|
"use strict";
|
|
5
5
|
function _interopDefaultLegacy(e) {
|
|
6
6
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
return Object.freeze(n);
|
|
27
27
|
}
|
|
28
28
|
var yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
29
|
+
var UrlPattern__default = /* @__PURE__ */ _interopDefaultLegacy(UrlPattern);
|
|
29
30
|
var z__default = /* @__PURE__ */ _interopDefaultLegacy(z);
|
|
30
31
|
function addNamespaceToSchema(maybeNode, namespace = []) {
|
|
31
32
|
if (typeof maybeNode === "string") {
|
|
@@ -141,6 +142,50 @@
|
|
|
141
142
|
} else
|
|
142
143
|
return void 0;
|
|
143
144
|
}
|
|
145
|
+
const TINA_HOST = "content.tinajs.io";
|
|
146
|
+
const parseURL = (url) => {
|
|
147
|
+
if (url.startsWith("/")) {
|
|
148
|
+
return {
|
|
149
|
+
branch: null,
|
|
150
|
+
isLocalClient: false,
|
|
151
|
+
clientId: null,
|
|
152
|
+
host: null
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (url.includes("localhost")) {
|
|
156
|
+
return {
|
|
157
|
+
branch: null,
|
|
158
|
+
isLocalClient: true,
|
|
159
|
+
clientId: null,
|
|
160
|
+
host: "localhost"
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
const params = new URL(url);
|
|
164
|
+
const isTinaCloud = params.host.includes("tinajs.dev") || params.host.includes("tina.io") || params.host.includes("tinajs.io");
|
|
165
|
+
if (!isTinaCloud) {
|
|
166
|
+
return {
|
|
167
|
+
branch: null,
|
|
168
|
+
isLocalClient: true,
|
|
169
|
+
clientId: null,
|
|
170
|
+
host: params.host
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const pattern = new UrlPattern__default["default"]("/content/:clientId/github/*", {
|
|
174
|
+
escapeChar: " "
|
|
175
|
+
});
|
|
176
|
+
const result = pattern.match(params.pathname);
|
|
177
|
+
const branch = result == null ? void 0 : result._;
|
|
178
|
+
const clientId = result == null ? void 0 : result.clientId;
|
|
179
|
+
if (!branch || !clientId) {
|
|
180
|
+
throw new Error(`Invalid URL format provided. Expected: https://content.tinajs.io/content/<ClientID>/github/<Branch> but but received ${url}`);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
host: params.host,
|
|
184
|
+
branch,
|
|
185
|
+
clientId,
|
|
186
|
+
isLocalClient: false
|
|
187
|
+
};
|
|
188
|
+
};
|
|
144
189
|
class TinaSchema {
|
|
145
190
|
constructor(config) {
|
|
146
191
|
this.config = config;
|
|
@@ -320,7 +365,15 @@
|
|
|
320
365
|
return { [_template]: this.transformCollectablePayload(rest, field) };
|
|
321
366
|
}
|
|
322
367
|
} else {
|
|
323
|
-
|
|
368
|
+
if (field.list) {
|
|
369
|
+
assertShape(value, (yup2) => yup2.array(yup2.object()));
|
|
370
|
+
return value.map((item) => {
|
|
371
|
+
return this.transformCollectablePayload(item, field);
|
|
372
|
+
});
|
|
373
|
+
} else {
|
|
374
|
+
assertShape(value, (yup2) => yup2.object());
|
|
375
|
+
return this.transformCollectablePayload(value, field);
|
|
376
|
+
}
|
|
324
377
|
}
|
|
325
378
|
else {
|
|
326
379
|
return value;
|
|
@@ -804,7 +857,14 @@ ${JSON.stringify(val, null, 2)}
|
|
|
804
857
|
});
|
|
805
858
|
const TinaCloudCollectionBase = z.z.object({
|
|
806
859
|
label: z.z.string().optional(),
|
|
807
|
-
name,
|
|
860
|
+
name: name.superRefine((val, ctx) => {
|
|
861
|
+
if (val === "relativePath") {
|
|
862
|
+
ctx.addIssue({
|
|
863
|
+
code: z.z.ZodIssueCode.custom,
|
|
864
|
+
message: `name cannot be 'relativePath'. 'relativePath' is a reserved field name.`
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
}),
|
|
808
868
|
format: z.z.enum(FORMATS).optional()
|
|
809
869
|
});
|
|
810
870
|
const TinaCloudCollection = TinaCloudCollectionBase.extend({
|
|
@@ -884,9 +944,11 @@ ${JSON.stringify(val, null, 2)}
|
|
|
884
944
|
}
|
|
885
945
|
};
|
|
886
946
|
exports2.NAMER = NAMER;
|
|
947
|
+
exports2.TINA_HOST = TINA_HOST;
|
|
887
948
|
exports2.TinaSchema = TinaSchema;
|
|
888
949
|
exports2.TinaSchemaValidationError = TinaSchemaValidationError;
|
|
889
950
|
exports2.addNamespaceToSchema = addNamespaceToSchema;
|
|
951
|
+
exports2.parseURL = parseURL;
|
|
890
952
|
exports2.resolveField = resolveField;
|
|
891
953
|
exports2.resolveForm = resolveForm;
|
|
892
954
|
exports2.validateSchema = validateSchema;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { TinaCloudSchemaEnriched, TinaCloudSchemaBase, TinaCloudCollection, Templateable, Collectable, CollectionTemplateable } from '../types/index';
|
|
14
5
|
declare type Version = {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export declare function addNamespaceToSchema<T extends object | string>(maybeNode: T, namespace?: string[]): T;
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export * from './addNamespaceToSchema';
|
|
14
5
|
export * from './TinaSchema';
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { TinaFieldEnriched } from '../types/index';
|
|
14
5
|
import { TinaSchema } from './TinaSchema';
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import type { ResolveFormArgs } from '../types/index';
|
|
14
5
|
/**
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import type { FC } from 'react';
|
|
14
5
|
import { TinaSchema } from '../schema';
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export interface TinaCloudSchemaConfig<Store = any> {
|
|
14
5
|
client?: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
|
|
3
|
-
Copyright 2021 Forestry.io Holdings, Inc.
|
|
4
3
|
|
|
5
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
you may not use this file except in compliance with the License.
|
|
7
|
-
You may obtain a copy of the License at
|
|
8
|
-
|
|
9
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
|
|
11
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
See the License for the specific language governing permissions and
|
|
15
|
-
limitations under the License.
|
|
16
4
|
|
|
17
5
|
*/
|
|
18
6
|
export * from './SchemaTypes';
|
package/dist/types/schema2.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { Option, UICollection } from './SchemaTypes';
|
|
14
5
|
/**
|
package/dist/types/types2.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
/**
|
|
14
5
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
declare type Doc = {
|
|
14
5
|
_sys: {
|
|
@@ -386,12 +377,47 @@ export interface Schema {
|
|
|
386
377
|
}
|
|
387
378
|
export declare type TokenObject = {
|
|
388
379
|
id_token: string;
|
|
389
|
-
access_token
|
|
390
|
-
refresh_token
|
|
380
|
+
access_token?: string;
|
|
381
|
+
refresh_token?: string;
|
|
391
382
|
};
|
|
392
383
|
export interface Config<CMSCallback = undefined, FormifyCallback = undefined, DocumentCreatorCallback = undefined, Store = undefined> {
|
|
384
|
+
contentApiUrlOverride?: string;
|
|
393
385
|
admin?: {
|
|
394
386
|
auth?: {
|
|
387
|
+
/**
|
|
388
|
+
* If you wish to use the local auth provider, set this to true
|
|
389
|
+
*
|
|
390
|
+
* This will take precedence over the customAuth option (if set to true)
|
|
391
|
+
*
|
|
392
|
+
**/
|
|
393
|
+
useLocalAuth?: boolean;
|
|
394
|
+
/**
|
|
395
|
+
* If you are using a custom auth provider, set this to true
|
|
396
|
+
**/
|
|
397
|
+
customAuth?: boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Used for getting the token from the custom auth provider
|
|
400
|
+
*
|
|
401
|
+
* @returns {Promise<TokenObject | null>}
|
|
402
|
+
**/
|
|
403
|
+
getToken?: () => Promise<TokenObject | null>;
|
|
404
|
+
/**
|
|
405
|
+
* Used to logout from the custom auth provider
|
|
406
|
+
*
|
|
407
|
+
**/
|
|
408
|
+
logout?: () => Promise<void>;
|
|
409
|
+
/**
|
|
410
|
+
* Used for getting the user from the custom auth provider. If this returns a truthy value, the user will be logged in and the CMS will be enabled.
|
|
411
|
+
*
|
|
412
|
+
* If this returns a falsy value, the user will be logged out and the CMS will be disabled.
|
|
413
|
+
*
|
|
414
|
+
**/
|
|
415
|
+
getUser?: () => Promise<any | null>;
|
|
416
|
+
/**
|
|
417
|
+
* Used to authenticate the user with the custom auth provider. This is called when the user clicks the login button.
|
|
418
|
+
*
|
|
419
|
+
**/
|
|
420
|
+
authenticate?: () => Promise<any | null>;
|
|
395
421
|
onLogin?: (args: {
|
|
396
422
|
token: TokenObject;
|
|
397
423
|
}) => Promise<void>;
|
|
@@ -426,6 +452,19 @@ export interface Config<CMSCallback = undefined, FormifyCallback = undefined, Do
|
|
|
426
452
|
*/
|
|
427
453
|
referenceDepth?: number;
|
|
428
454
|
};
|
|
455
|
+
/**
|
|
456
|
+
*
|
|
457
|
+
* Tina supports serving content from a separate Git repo. To enable this during local development, point
|
|
458
|
+
* this config at the root of the content repo.
|
|
459
|
+
*
|
|
460
|
+
* NOTE: Relative paths are fine to use here, but you should use an environment variable for this, as each developer on your team may have a different
|
|
461
|
+
* location to the path.
|
|
462
|
+
*
|
|
463
|
+
* ```ts
|
|
464
|
+
* localContentPath: process.env.REMOTE_ROOT_PATH // eg. '../../my-content-repo'
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
localContentPath?: string;
|
|
429
468
|
/**
|
|
430
469
|
* Tina is compiled as a single-page app and placed in the public directory
|
|
431
470
|
* of your application.
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export declare function hasDuplicates<T = any>(array?: T[]): boolean;
|
|
14
5
|
/**
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export * from './validate';
|
|
14
5
|
export * from './lastItem';
|
|
15
6
|
export * from './namer';
|
|
16
7
|
export * from './sequential';
|
|
17
8
|
export * from './hasDuplicates';
|
|
9
|
+
export * from './parseURL';
|
package/dist/util/lastItem.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export declare const lastItem: (arr: (number | string)[]) => string | number;
|
package/dist/util/namer.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
export declare const NAMER: {
|
|
14
5
|
dataFilterTypeNameOn: (namespace: string[]) => string;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import type { ZodError } from 'zod';
|
|
14
5
|
export declare const parseZodError: ({ zodError }: {
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
/**
|
|
14
5
|
* Iterate through an array of promises sequentially, ensuring the order
|
package/dist/util/validate.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import * as yup from 'yup';
|
|
14
5
|
import type { AnySchema } from 'yup';
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { z } from 'zod';
|
|
14
5
|
import { TinaFieldInner } from '../types/SchemaTypes';
|
package/dist/validate/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { Schema } from '../types';
|
|
14
5
|
import { TinaCloudSchema } from '../types/index';
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { z } from 'zod';
|
|
14
5
|
export declare const name: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { z } from 'zod';
|
|
14
5
|
export declare const TinaCloudSchemaZod: z.ZodEffects<z.ZodObject<{
|
|
15
6
|
collections: z.ZodArray<z.ZodEffects<z.ZodObject<z.extendShape<{
|
|
16
7
|
label: z.ZodOptional<z.ZodString>;
|
|
17
|
-
name: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
+
name: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
18
9
|
format: z.ZodOptional<z.ZodEnum<["json", "md", "markdown", "mdx", "toml", "yaml"]>>;
|
|
19
10
|
}, {
|
|
20
11
|
fields: z.ZodEffects<z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodType<import("..").TinaFieldInner<false>, z.ZodTypeDef, import("..").TinaFieldInner<false>>, "many">>, import("..").TinaFieldInner<false>[], import("..").TinaFieldInner<false>[]>, import("..").TinaFieldInner<false>[], import("..").TinaFieldInner<false>[]>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
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.
|
|
2
|
+
|
|
12
3
|
*/
|
|
13
4
|
import { TinaCloudSchemaConfig } from '../types/index';
|
|
14
5
|
import z from 'zod';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/schema-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tinacms/scripts": "1.0.
|
|
34
|
+
"@tinacms/scripts": "1.0.2",
|
|
35
35
|
"@types/yup": "^0.29.10",
|
|
36
36
|
"jest": "^27.0.6",
|
|
37
37
|
"react": "17.0.2",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"directory": "packages/@tinacms/cli"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"url-pattern": "^1.0.3",
|
|
53
54
|
"zod": "^3.14.3"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|