@tinacms/schema-tools 2.8.2 → 2.8.3
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/dist/errors.d.ts +37 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -0
- package/dist/util/relativePath.d.ts +6 -0
- package/package.json +1 -1
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Path-collision fragment thrown by the @tinacms/graphql resolver. */
|
|
2
|
+
export declare const ERR_ALREADY_EXISTS = "already exists";
|
|
3
|
+
/** AsyncPoller lifecycle signals (tinacms internalClient). */
|
|
4
|
+
export declare const ASYNC_POLLER_ERROR: {
|
|
5
|
+
readonly CANCELLED: "AsyncPoller: cancelled";
|
|
6
|
+
readonly TIMEOUT: "AsyncPoller: reached timeout";
|
|
7
|
+
readonly STATUS_UNKNOWN: "AsyncPoller: status unknown for too long, please check indexing progress on the TinaCloud dashboard";
|
|
8
|
+
};
|
|
9
|
+
export type AsyncPollerError = (typeof ASYNC_POLLER_ERROR)[keyof typeof ASYNC_POLLER_ERROR];
|
|
10
|
+
/**
|
|
11
|
+
* Filesystem path-traversal prefix (CWE-22). The full emitted message MUST
|
|
12
|
+
* keep this exact prefix — do not reword.
|
|
13
|
+
*
|
|
14
|
+
* The path-traversal producers (the @tinacms/graphql filesystem and isomorphic
|
|
15
|
+
* bridges, and the @tinacms/cli path guard) inline this literal rather than
|
|
16
|
+
* importing the constant: those modules are loaded by jest from source across a
|
|
17
|
+
* package boundary, where importing the schema-tools ESM build throws "Cannot
|
|
18
|
+
* use import statement outside a module". This is the canonical reference for
|
|
19
|
+
* the string; keep the inlined literals byte-identical to it. The real contract
|
|
20
|
+
* is enforced by the `toThrow('Path traversal detected')` assertions in the
|
|
21
|
+
* bridge and CLI suites, not by this constant.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ERR_PATH_TRAVERSAL = "Path traversal detected";
|
|
24
|
+
/** TinaCloud: a document still has inbound references on delete/rename. */
|
|
25
|
+
export declare const ERR_HAS_REFERENCES = "has references";
|
|
26
|
+
/** TinaCloud: the branch schema has not finished indexing. */
|
|
27
|
+
export declare const ERR_NOT_INDEXED = "has not been indexed by TinaCloud";
|
|
28
|
+
/** TinaCloud: a branch with the given name already exists (editorial workflow). */
|
|
29
|
+
export declare const ERR_BRANCH_EXISTS = "already exists";
|
|
30
|
+
/**
|
|
31
|
+
* TinaCloud: branch-name conflict (editorial workflow fallback path). Broad by
|
|
32
|
+
* necessity — this matches the substring of an external server message we do
|
|
33
|
+
* not own, so it cannot be narrowed without risking a missed match. The
|
|
34
|
+
* structured `errorCode` switch above is the preferred path; this is the
|
|
35
|
+
* no-code fallback.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ERR_BRANCH_CONFLICT = "conflict";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2812,6 +2812,9 @@ const validateSchema = ({ schema }) => {
|
|
|
2812
2812
|
throw new Error(e);
|
|
2813
2813
|
}
|
|
2814
2814
|
};
|
|
2815
|
+
const RELATIVE_PATH_REGEX = /^[a-zA-Z0-9\-_./]+$/;
|
|
2816
|
+
const RELATIVE_PATH_ALLOWED_CHARS_MESSAGE = "Must contain only a-z, A-Z, 0-9, -, _, ., or /.";
|
|
2817
|
+
const isValidRelativePath = (value) => RELATIVE_PATH_REGEX.test(value);
|
|
2815
2818
|
const isHeadingLevel = (value) => {
|
|
2816
2819
|
switch (value) {
|
|
2817
2820
|
case "h1":
|
|
@@ -2833,16 +2836,37 @@ const normalizeHeadingLevels = (configured) => {
|
|
|
2833
2836
|
}
|
|
2834
2837
|
return Array.from(seen);
|
|
2835
2838
|
};
|
|
2839
|
+
const ERR_ALREADY_EXISTS = "already exists";
|
|
2840
|
+
const ASYNC_POLLER_ERROR = {
|
|
2841
|
+
CANCELLED: "AsyncPoller: cancelled",
|
|
2842
|
+
TIMEOUT: "AsyncPoller: reached timeout",
|
|
2843
|
+
STATUS_UNKNOWN: "AsyncPoller: status unknown for too long, please check indexing progress on the TinaCloud dashboard"
|
|
2844
|
+
};
|
|
2845
|
+
const ERR_PATH_TRAVERSAL = "Path traversal detected";
|
|
2846
|
+
const ERR_HAS_REFERENCES = "has references";
|
|
2847
|
+
const ERR_NOT_INDEXED = "has not been indexed by TinaCloud";
|
|
2848
|
+
const ERR_BRANCH_EXISTS = "already exists";
|
|
2849
|
+
const ERR_BRANCH_CONFLICT = "conflict";
|
|
2836
2850
|
export {
|
|
2837
2851
|
ALL_HEADING_LEVELS,
|
|
2852
|
+
ASYNC_POLLER_ERROR,
|
|
2838
2853
|
CONTENT_FORMATS,
|
|
2854
|
+
ERR_ALREADY_EXISTS,
|
|
2855
|
+
ERR_BRANCH_CONFLICT,
|
|
2856
|
+
ERR_BRANCH_EXISTS,
|
|
2857
|
+
ERR_HAS_REFERENCES,
|
|
2858
|
+
ERR_NOT_INDEXED,
|
|
2859
|
+
ERR_PATH_TRAVERSAL,
|
|
2839
2860
|
NAMER,
|
|
2861
|
+
RELATIVE_PATH_ALLOWED_CHARS_MESSAGE,
|
|
2862
|
+
RELATIVE_PATH_REGEX,
|
|
2840
2863
|
TINA_HOST,
|
|
2841
2864
|
TinaSchema,
|
|
2842
2865
|
TinaSchemaValidationError,
|
|
2843
2866
|
addNamespaceToSchema,
|
|
2844
2867
|
canonicalPath,
|
|
2845
2868
|
isHeadingLevel,
|
|
2869
|
+
isValidRelativePath,
|
|
2846
2870
|
normalizeHeadingLevels,
|
|
2847
2871
|
normalizePath,
|
|
2848
2872
|
parseURL,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Allowlist for a relativePath segment (filename or folder name); source of truth shared with the resolver's validateRelativePath so the UI can reject invalid names inline. */
|
|
2
|
+
export declare const RELATIVE_PATH_REGEX: RegExp;
|
|
3
|
+
/** Inline form-validation message for {@link RELATIVE_PATH_REGEX}. */
|
|
4
|
+
export declare const RELATIVE_PATH_ALLOWED_CHARS_MESSAGE = "Must contain only a-z, A-Z, 0-9, -, _, ., or /.";
|
|
5
|
+
/** True when `value` contains only characters allowed in a relativePath. */
|
|
6
|
+
export declare const isValidRelativePath: (value: string) => boolean;
|