@tinacms/graphql 0.0.0-0a77b75-20241004023651
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 +176 -0
- package/dist/ast-builder/index.d.ts +180 -0
- package/dist/auth/utils.d.ts +22 -0
- package/dist/build.d.ts +18 -0
- package/dist/builder/index.d.ts +268 -0
- package/dist/builder/static-definitions.d.ts +4 -0
- package/dist/database/alias-utils.d.ts +3 -0
- package/dist/database/bridge/filesystem.d.ts +21 -0
- package/dist/database/bridge/index.d.ts +12 -0
- package/dist/database/bridge/isomorphic.d.ts +94 -0
- package/dist/database/datalayer.d.ts +76 -0
- package/dist/database/index.d.ts +201 -0
- package/dist/database/level.d.ts +28 -0
- package/dist/database/util.d.ts +33 -0
- package/dist/error.d.ts +4 -0
- package/dist/git/index.d.ts +23 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +7394 -0
- package/dist/index.mjs +7313 -0
- package/dist/level/tinaLevel.d.ts +7 -0
- package/dist/mdx/index.d.ts +8 -0
- package/dist/resolve.d.ts +21 -0
- package/dist/resolver/error.d.ts +46 -0
- package/dist/resolver/filter-utils.d.ts +13 -0
- package/dist/resolver/index.d.ts +352 -0
- package/dist/resolver/media-utils.d.ts +21 -0
- package/dist/schema/createSchema.d.ts +8 -0
- package/dist/schema/validate.d.ts +11 -0
- package/dist/sdkBuilder/index.d.ts +5 -0
- package/dist/spec/setup.d.ts +32 -0
- package/dist/types.d.ts +10 -0
- package/dist/util.d.ts +21 -0
- package/package.json +91 -0
- package/readme.md +194 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Bridge } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* This is the bridge from whatever datasource we need for I/O.
|
|
4
|
+
* The basic example here is for the filesystem, one is needed
|
|
5
|
+
* for GitHub has well.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FilesystemBridge implements Bridge {
|
|
8
|
+
rootPath: string;
|
|
9
|
+
outputPath?: string;
|
|
10
|
+
constructor(rootPath: string, outputPath?: string);
|
|
11
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
12
|
+
delete(filepath: string): Promise<void>;
|
|
13
|
+
get(filepath: string): Promise<string>;
|
|
14
|
+
put(filepath: string, data: string, basePathOverride?: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Same as the `FileSystemBridge` except it does not save files
|
|
18
|
+
*/
|
|
19
|
+
export declare class AuditFileSystemBridge extends FilesystemBridge {
|
|
20
|
+
put(filepath: string, data: string): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Bridge {
|
|
2
|
+
rootPath: string;
|
|
3
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
4
|
+
delete(filepath: string): Promise<void>;
|
|
5
|
+
get(filepath: string): Promise<string>;
|
|
6
|
+
put(filepath: string, data: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Optionally, the bridge can perform
|
|
9
|
+
* operations in a separate path.
|
|
10
|
+
*/
|
|
11
|
+
outputPath?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
|
|
2
|
+
import type { Bridge } from './index';
|
|
3
|
+
export type IsomorphicGitBridgeOptions = {
|
|
4
|
+
gitRoot: string;
|
|
5
|
+
fsModule?: CallbackFsClient | PromiseFsClient;
|
|
6
|
+
commitMessage?: string;
|
|
7
|
+
author: {
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
};
|
|
11
|
+
committer?: {
|
|
12
|
+
name: string;
|
|
13
|
+
email: string;
|
|
14
|
+
};
|
|
15
|
+
ref?: string;
|
|
16
|
+
onPut?: (filepath: string, data: string) => Promise<void>;
|
|
17
|
+
onDelete?: (filepath: string) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Bridge backed by isomorphic-git
|
|
21
|
+
*/
|
|
22
|
+
export declare class IsomorphicBridge implements Bridge {
|
|
23
|
+
rootPath: string;
|
|
24
|
+
relativePath: string;
|
|
25
|
+
gitRoot: string;
|
|
26
|
+
fsModule: CallbackFsClient | PromiseFsClient;
|
|
27
|
+
isomorphicConfig: {
|
|
28
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
29
|
+
dir: string;
|
|
30
|
+
};
|
|
31
|
+
commitMessage: string;
|
|
32
|
+
author: {
|
|
33
|
+
name: string;
|
|
34
|
+
email: string;
|
|
35
|
+
};
|
|
36
|
+
committer: {
|
|
37
|
+
name: string;
|
|
38
|
+
email: string;
|
|
39
|
+
};
|
|
40
|
+
ref: string | undefined;
|
|
41
|
+
private readonly onPut;
|
|
42
|
+
private readonly onDelete;
|
|
43
|
+
private cache;
|
|
44
|
+
constructor(rootPath: string, { gitRoot, author, committer, fsModule, commitMessage, ref, onPut, onDelete, }: IsomorphicGitBridgeOptions);
|
|
45
|
+
private getAuthor;
|
|
46
|
+
private getCommitter;
|
|
47
|
+
/**
|
|
48
|
+
* Recursively populate paths matching `pattern` for the given `entry`
|
|
49
|
+
*
|
|
50
|
+
* @param pattern - pattern to filter paths by
|
|
51
|
+
* @param entry - TreeEntry to start building list from
|
|
52
|
+
* @param path - base path
|
|
53
|
+
* @param results
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private listEntries;
|
|
57
|
+
/**
|
|
58
|
+
* For the specified path, returns an object with an array containing the parts of the path (pathParts)
|
|
59
|
+
* and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
|
|
60
|
+
* pathEntries are placeholders for non-existent entries.
|
|
61
|
+
*
|
|
62
|
+
* @param path - path being resolved
|
|
63
|
+
* @param ref - ref to resolve path entries for
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private resolvePathEntries;
|
|
67
|
+
/**
|
|
68
|
+
* Updates tree entry and associated parent tree entries
|
|
69
|
+
*
|
|
70
|
+
* @param existingOid - the existing OID
|
|
71
|
+
* @param updatedOid - the updated OID
|
|
72
|
+
* @param path - the path of the entry being updated
|
|
73
|
+
* @param type - the type of the entry being updated (blob or tree)
|
|
74
|
+
* @param pathEntries - parent path entries
|
|
75
|
+
* @param pathParts - parent path parts
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private updateTreeHierarchy;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a commit for the specified tree and updates the specified ref to point to the commit
|
|
81
|
+
*
|
|
82
|
+
* @param treeSha - sha of the new tree
|
|
83
|
+
* @param ref - the ref that should be updated
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private commitTree;
|
|
87
|
+
private getRef;
|
|
88
|
+
glob(pattern: string, extension: string): Promise<string[]>;
|
|
89
|
+
delete(filepath: string): Promise<void>;
|
|
90
|
+
private qualifyPath;
|
|
91
|
+
private unqualifyPath;
|
|
92
|
+
get(filepath: string): Promise<string>;
|
|
93
|
+
put(filepath: string, data: string): Promise<void>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { BatchOp, Level } from './level';
|
|
5
|
+
import { Collection } from '@tinacms/schema-tools';
|
|
6
|
+
export declare enum OP {
|
|
7
|
+
EQ = "eq",
|
|
8
|
+
GT = "gt",
|
|
9
|
+
LT = "lt",
|
|
10
|
+
GTE = "gte",
|
|
11
|
+
LTE = "lte",
|
|
12
|
+
STARTS_WITH = "startsWith",
|
|
13
|
+
IN = "in"
|
|
14
|
+
}
|
|
15
|
+
export type BinaryFilter = {
|
|
16
|
+
pathExpression: string;
|
|
17
|
+
rightOperand: FilterOperand;
|
|
18
|
+
operator: OP.EQ | OP.GT | OP.LT | OP.GTE | OP.LTE | OP.STARTS_WITH | OP.IN;
|
|
19
|
+
type: string;
|
|
20
|
+
pad?: PadDefinition;
|
|
21
|
+
list: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type TernaryFilter = {
|
|
24
|
+
pathExpression: string;
|
|
25
|
+
leftOperand: FilterOperand;
|
|
26
|
+
rightOperand: FilterOperand;
|
|
27
|
+
leftOperator: OP.GTE | OP.GT;
|
|
28
|
+
rightOperator: OP.LT | OP.LTE;
|
|
29
|
+
type: string;
|
|
30
|
+
pad?: PadDefinition;
|
|
31
|
+
list: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type IndexDefinition = {
|
|
34
|
+
fields: {
|
|
35
|
+
name: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
pad?: PadDefinition;
|
|
38
|
+
list: boolean;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
export type PadDefinition = {
|
|
42
|
+
fillString: string;
|
|
43
|
+
maxLength: number;
|
|
44
|
+
};
|
|
45
|
+
export type FilterOperand = string | number | boolean | string[] | number[];
|
|
46
|
+
export type FilterCondition = {
|
|
47
|
+
filterExpression: Record<string, FilterOperand>;
|
|
48
|
+
filterPath: string;
|
|
49
|
+
};
|
|
50
|
+
type StringEscaper = <T extends string | string[]>(input: T) => T;
|
|
51
|
+
export declare const DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
|
|
52
|
+
export declare const DEFAULT_NUMERIC_LPAD = 4;
|
|
53
|
+
export declare const coerceFilterChainOperands: (filterChain: (BinaryFilter | TernaryFilter)[], escapeString?: StringEscaper) => (BinaryFilter | TernaryFilter)[];
|
|
54
|
+
export declare const makeFilter: ({ filterChain, }: {
|
|
55
|
+
filterChain?: (BinaryFilter | TernaryFilter)[];
|
|
56
|
+
}) => ((values: Record<string, object | FilterOperand>) => boolean);
|
|
57
|
+
export declare const makeFilterChain: ({ conditions, }: {
|
|
58
|
+
conditions: FilterCondition[];
|
|
59
|
+
}) => (BinaryFilter | TernaryFilter)[];
|
|
60
|
+
export declare const makeFilterSuffixes: (filterChain: (BinaryFilter | TernaryFilter)[], index: IndexDefinition) => {
|
|
61
|
+
left?: string;
|
|
62
|
+
right?: string;
|
|
63
|
+
} | undefined;
|
|
64
|
+
export declare const FOLDER_ROOT = "~";
|
|
65
|
+
type FolderTree = Record<string, Set<string>>;
|
|
66
|
+
export declare class FolderTreeBuilder {
|
|
67
|
+
_tree: FolderTree;
|
|
68
|
+
constructor();
|
|
69
|
+
get tree(): FolderTree;
|
|
70
|
+
update(documentPath: string, collectionPath: string): any;
|
|
71
|
+
}
|
|
72
|
+
export declare const makeFolderOpsForCollection: <T extends object>(folderTree: FolderTree, collection: Collection<true>, indexDefinitions: Record<string, IndexDefinition>, opType: "put" | "del", level: Level, escapeStr?: StringEscaper) => BatchOp[];
|
|
73
|
+
export declare const makeIndexOpsForDocument: <T extends object>(filepath: string, collection: string | undefined, indexDefinitions: Record<string, IndexDefinition>, data: T, opType: "put" | "del", level: Level, escapeStr?: StringEscaper) => BatchOp[];
|
|
74
|
+
export declare const makeStringEscaper: (regex: RegExp, replacement: string) => StringEscaper;
|
|
75
|
+
export declare const stringEscaper: StringEscaper;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { DocumentNode } from 'graphql';
|
|
2
|
+
import type { Collection, CollectionTemplateable, Schema, TinaSchema } from '@tinacms/schema-tools';
|
|
3
|
+
import type { Bridge } from './bridge';
|
|
4
|
+
import { type BinaryFilter, type IndexDefinition, type TernaryFilter } from './datalayer';
|
|
5
|
+
import { type Level } from './level';
|
|
6
|
+
type IndexStatusEvent = {
|
|
7
|
+
status: 'inprogress' | 'complete' | 'failed';
|
|
8
|
+
error?: Error;
|
|
9
|
+
};
|
|
10
|
+
type IndexStatusCallback = (event: IndexStatusEvent) => Promise<void>;
|
|
11
|
+
export type OnPutCallback = (key: string, value: any) => Promise<void>;
|
|
12
|
+
export type OnDeleteCallback = (key: string) => Promise<void>;
|
|
13
|
+
export interface DatabaseArgs {
|
|
14
|
+
bridge?: Bridge;
|
|
15
|
+
level: Level;
|
|
16
|
+
onPut?: (key: string, value: any) => Promise<void>;
|
|
17
|
+
onDelete?: (key: string) => Promise<void>;
|
|
18
|
+
tinaDirectory?: string;
|
|
19
|
+
indexStatusCallback?: IndexStatusCallback;
|
|
20
|
+
version?: boolean;
|
|
21
|
+
namespace?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GitProvider {
|
|
24
|
+
onPut: (key: string, value: string) => Promise<void>;
|
|
25
|
+
onDelete: (key: string) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export type CreateDatabase = Omit<DatabaseArgs, 'level' | 'onPut' | 'onDelete'> & {
|
|
28
|
+
databaseAdapter: Level;
|
|
29
|
+
gitProvider: GitProvider;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use databaseAdapter instead
|
|
32
|
+
*/
|
|
33
|
+
level?: Level;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use gitProvider instead
|
|
36
|
+
*/
|
|
37
|
+
onPut?: OnPutCallback;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated Use gitProvider instead
|
|
40
|
+
*/
|
|
41
|
+
onDelete?: OnDeleteCallback;
|
|
42
|
+
};
|
|
43
|
+
export type CreateLocalDatabaseArgs = Omit<DatabaseArgs, 'level'> & {
|
|
44
|
+
port?: number;
|
|
45
|
+
rootPath?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const createLocalDatabase: (config?: CreateLocalDatabaseArgs) => Database;
|
|
48
|
+
export declare const createDatabase: (config: CreateDatabase) => Database;
|
|
49
|
+
export declare const createDatabaseInternal: (config: DatabaseArgs) => Database;
|
|
50
|
+
/** Options for {@link Database.query} **/
|
|
51
|
+
export type QueryOptions = {
|
|
52
|
+
fileExtension?: string;
|
|
53
|
+
collection: string;
|
|
54
|
+
filterChain?: (BinaryFilter | TernaryFilter)[];
|
|
55
|
+
sort?: string;
|
|
56
|
+
first?: number;
|
|
57
|
+
last?: number;
|
|
58
|
+
after?: string;
|
|
59
|
+
before?: string;
|
|
60
|
+
folder?: string;
|
|
61
|
+
};
|
|
62
|
+
export declare class Database {
|
|
63
|
+
config: DatabaseArgs;
|
|
64
|
+
bridge?: Bridge;
|
|
65
|
+
rootLevel: Level;
|
|
66
|
+
appLevel: Level | undefined;
|
|
67
|
+
contentLevel: Level | undefined;
|
|
68
|
+
tinaDirectory: string;
|
|
69
|
+
indexStatusCallback: IndexStatusCallback | undefined;
|
|
70
|
+
private readonly onPut;
|
|
71
|
+
private readonly onDelete;
|
|
72
|
+
private tinaSchema;
|
|
73
|
+
private contentNamespace;
|
|
74
|
+
private collectionIndexDefinitions;
|
|
75
|
+
private _lookup;
|
|
76
|
+
constructor(config: DatabaseArgs);
|
|
77
|
+
private collectionForPath;
|
|
78
|
+
private getGeneratedFolder;
|
|
79
|
+
private updateDatabaseVersion;
|
|
80
|
+
private getDatabaseVersion;
|
|
81
|
+
private initLevel;
|
|
82
|
+
getMetadata: (key: string) => Promise<any>;
|
|
83
|
+
setMetadata: (key: string, value: string) => Promise<void>;
|
|
84
|
+
get: <T extends object>(filepath: string) => Promise<T>;
|
|
85
|
+
addPendingDocument: (filepath: string, data: {
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}) => Promise<void>;
|
|
88
|
+
put: (filepath: string, data: {
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}, collectionName?: string) => Promise<boolean>;
|
|
91
|
+
getTemplateDetailsForFile(collection: Collection<true>, data: {
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
template: {
|
|
95
|
+
label?: string | boolean;
|
|
96
|
+
name: string;
|
|
97
|
+
nameOverride?: string;
|
|
98
|
+
ui?: {
|
|
99
|
+
itemProps?(item: Record<string, any>): {
|
|
100
|
+
key?: string;
|
|
101
|
+
label?: string | boolean;
|
|
102
|
+
};
|
|
103
|
+
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
104
|
+
previewSrc?: string;
|
|
105
|
+
};
|
|
106
|
+
fields: ((import("@tinacms/schema-tools").StringField | import("@tinacms/schema-tools").NumberField | import("@tinacms/schema-tools").BooleanField | import("@tinacms/schema-tools").DateTimeField | import("@tinacms/schema-tools").ImageField | import("@tinacms/schema-tools").ReferenceField | import("@tinacms/schema-tools").PasswordField | import("@tinacms/schema-tools").RichTextField<false> | import("@tinacms/schema-tools").ObjectField<false>) & {})[];
|
|
107
|
+
};
|
|
108
|
+
info: CollectionTemplateable;
|
|
109
|
+
}>;
|
|
110
|
+
formatBodyOnPayload: (filepath: string, data: {
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}) => Promise<{
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
}>;
|
|
115
|
+
stringifyFile: (filepath: string, payload: {
|
|
116
|
+
[key: string]: unknown;
|
|
117
|
+
}, collection: Collection<true>) => Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Clears the internal cache of the tinaSchema and the lookup file. This allows the state to be reset
|
|
120
|
+
*/
|
|
121
|
+
clearCache(): void;
|
|
122
|
+
flush: (filepath: string) => Promise<string>;
|
|
123
|
+
getLookup: (returnType?: string) => Promise<LookupMapType | Record<string, LookupMapType>>;
|
|
124
|
+
getGraphQLSchema: () => Promise<DocumentNode>;
|
|
125
|
+
getGraphQLSchemaFromBridge: () => Promise<DocumentNode>;
|
|
126
|
+
getTinaSchema: (level?: Level) => Promise<Schema>;
|
|
127
|
+
getSchema: (level?: Level, existingSchema?: Schema) => Promise<TinaSchema>;
|
|
128
|
+
getIndexDefinitions: (level?: Level) => Promise<Record<string, Record<string, IndexDefinition>>>;
|
|
129
|
+
documentExists: (fullpath: unknown) => Promise<boolean>;
|
|
130
|
+
query: (queryOptions: QueryOptions, hydrator: any) => Promise<{
|
|
131
|
+
edges: {
|
|
132
|
+
node: any;
|
|
133
|
+
cursor: string;
|
|
134
|
+
}[];
|
|
135
|
+
pageInfo: {
|
|
136
|
+
hasPreviousPage: boolean;
|
|
137
|
+
hasNextPage: boolean;
|
|
138
|
+
startCursor: string;
|
|
139
|
+
endCursor: string;
|
|
140
|
+
};
|
|
141
|
+
}>;
|
|
142
|
+
private indexStatusCallbackWrapper;
|
|
143
|
+
indexContent: ({ graphQLSchema, tinaSchema, lookup: lookupFromLockFile, }: {
|
|
144
|
+
graphQLSchema: DocumentNode;
|
|
145
|
+
tinaSchema: TinaSchema;
|
|
146
|
+
lookup?: object;
|
|
147
|
+
}) => Promise<{
|
|
148
|
+
warnings: string[];
|
|
149
|
+
}>;
|
|
150
|
+
deleteContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
151
|
+
indexContentByPaths: (documentPaths: string[]) => Promise<void>;
|
|
152
|
+
delete: (filepath: string) => Promise<void>;
|
|
153
|
+
_indexAllContent: (level: Level, schema?: Schema) => Promise<{
|
|
154
|
+
warnings: string[];
|
|
155
|
+
}>;
|
|
156
|
+
}
|
|
157
|
+
export type LookupMapType = GlobalDocumentLookup | CollectionDocumentLookup | CollectionFolderLookup | MultiCollectionDocumentLookup | MultiCollectionDocumentListLookup | CollectionDocumentListLookup | UnionDataLookup | NodeDocument;
|
|
158
|
+
type NodeDocument = {
|
|
159
|
+
type: string;
|
|
160
|
+
resolveType: 'nodeDocument';
|
|
161
|
+
};
|
|
162
|
+
type GlobalDocumentLookup = {
|
|
163
|
+
type: string;
|
|
164
|
+
resolveType: 'globalDocument';
|
|
165
|
+
collection: string;
|
|
166
|
+
};
|
|
167
|
+
type CollectionDocumentLookup = {
|
|
168
|
+
type: string;
|
|
169
|
+
resolveType: 'collectionDocument';
|
|
170
|
+
collection: string;
|
|
171
|
+
};
|
|
172
|
+
type CollectionFolderLookup = {
|
|
173
|
+
type: string;
|
|
174
|
+
resolveType: 'collectionFolder';
|
|
175
|
+
collection: string;
|
|
176
|
+
};
|
|
177
|
+
type MultiCollectionDocumentLookup = {
|
|
178
|
+
type: string;
|
|
179
|
+
resolveType: 'multiCollectionDocument';
|
|
180
|
+
createDocument: 'create';
|
|
181
|
+
updateDocument: 'update';
|
|
182
|
+
};
|
|
183
|
+
type MultiCollectionDocumentListLookup = {
|
|
184
|
+
type: string;
|
|
185
|
+
resolveType: 'multiCollectionDocumentList';
|
|
186
|
+
collections: string[];
|
|
187
|
+
};
|
|
188
|
+
export type CollectionDocumentListLookup = {
|
|
189
|
+
type: string;
|
|
190
|
+
resolveType: 'collectionDocumentList';
|
|
191
|
+
collection: string;
|
|
192
|
+
};
|
|
193
|
+
type UnionDataLookup = {
|
|
194
|
+
type: string;
|
|
195
|
+
resolveType: 'unionData';
|
|
196
|
+
collection?: string;
|
|
197
|
+
typeMap: {
|
|
198
|
+
[templateName: string]: string;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import { AbstractLevel, AbstractSublevel, AbstractSublevelOptions } from 'abstract-level';
|
|
5
|
+
export type Level = AbstractLevel<Buffer | Uint8Array | string, string, Record<string, any>>;
|
|
6
|
+
export type PutOp = {
|
|
7
|
+
type: 'put';
|
|
8
|
+
key: string;
|
|
9
|
+
value: Record<string, any>;
|
|
10
|
+
sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, any>>;
|
|
11
|
+
};
|
|
12
|
+
export type DelOp = {
|
|
13
|
+
type: 'del';
|
|
14
|
+
key: string;
|
|
15
|
+
sublevel?: AbstractSublevel<Level, Buffer | Uint8Array | string, string, Record<string, Record<string, any>>>;
|
|
16
|
+
};
|
|
17
|
+
export type BatchOp = PutOp | DelOp;
|
|
18
|
+
export declare const ARRAY_ITEM_VALUE_SEPARATOR = ",";
|
|
19
|
+
export declare const INDEX_KEY_FIELD_SEPARATOR = "\u001D";
|
|
20
|
+
export declare const CONTENT_ROOT_PREFIX = "~";
|
|
21
|
+
export declare const SUBLEVEL_OPTIONS: AbstractSublevelOptions<string, Record<string, any>>;
|
|
22
|
+
export declare class LevelWrapper {
|
|
23
|
+
private level;
|
|
24
|
+
constructor(level: Level);
|
|
25
|
+
}
|
|
26
|
+
export declare class LevelProxy {
|
|
27
|
+
constructor(level: Level);
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
*/
|
|
4
|
+
import * as yup from 'yup';
|
|
5
|
+
import { Collection, CollectionTemplateable, normalizePath, TinaSchema } from '@tinacms/schema-tools';
|
|
6
|
+
import { Bridge } from './bridge';
|
|
7
|
+
export { normalizePath };
|
|
8
|
+
export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean, markdownParseConfig?: {
|
|
9
|
+
frontmatterFormat?: "toml" | "yaml" | "json";
|
|
10
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
11
|
+
}) => string;
|
|
12
|
+
export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>, markdownParseConfig?: {
|
|
13
|
+
frontmatterFormat?: "toml" | "yaml" | "json";
|
|
14
|
+
frontmatterDelimiters?: [string, string] | string;
|
|
15
|
+
}) => T;
|
|
16
|
+
export type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
|
|
17
|
+
export declare const atob: (b64Encoded: string) => string;
|
|
18
|
+
export declare const btoa: (string: string) => string;
|
|
19
|
+
export declare const scanAllContent: (tinaSchema: TinaSchema, bridge: Bridge, callback: (collection: Collection<true>, contentPaths: string[]) => Promise<void>) => Promise<string[]>;
|
|
20
|
+
export declare const scanContentByPaths: (tinaSchema: TinaSchema, documentPaths: string[], callback: (collection: Collection<true> | undefined, documentPaths: string[]) => Promise<void>) => Promise<void>;
|
|
21
|
+
export declare const partitionPathsByCollection: (tinaSchema: TinaSchema, documentPaths: string[]) => Promise<{
|
|
22
|
+
pathsByCollection: Record<string, string[]>;
|
|
23
|
+
nonCollectionPaths: string[];
|
|
24
|
+
collections: Record<string, Collection<true>>;
|
|
25
|
+
}>;
|
|
26
|
+
/** TODO help needed with name of this function **/
|
|
27
|
+
export declare const transformDocument: <T extends object>(filepath: string, contentObject: any, tinaSchema: TinaSchema) => T;
|
|
28
|
+
export declare function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
29
|
+
export declare const getTemplateForFile: (templateInfo: CollectionTemplateable, data: {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}) => import("@tinacms/schema-tools").Template<true>;
|
|
32
|
+
/** TODO help needed with name of this function **/
|
|
33
|
+
export declare const loadAndParseWithAliases: (bridge: Bridge, filepath: string, collection?: Collection<true>, templateInfo?: CollectionTemplateable) => Promise<object>;
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ASTNode, GraphQLError, GraphQLErrorExtensions, Source } from 'graphql';
|
|
2
|
+
export declare class NotFoundError extends GraphQLError {
|
|
3
|
+
constructor(message: string, nodes?: ASTNode | readonly ASTNode[], source?: Source, positions?: readonly number[], path?: readonly (string | number)[], originalError?: Error, extensions?: GraphQLErrorExtensions);
|
|
4
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
|
|
2
|
+
export declare const getSha: ({ fs, dir, }: {
|
|
3
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
4
|
+
dir: string;
|
|
5
|
+
}) => Promise<string>;
|
|
6
|
+
export declare const getChangedFiles: ({ fs, dir, from, to, pathFilter, }: {
|
|
7
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
8
|
+
dir: string;
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
pathFilter: Record<string, {
|
|
12
|
+
matches?: string[];
|
|
13
|
+
}>;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
added: any[];
|
|
16
|
+
modified: any[];
|
|
17
|
+
deleted: any[];
|
|
18
|
+
}>;
|
|
19
|
+
export declare const shaExists: ({ fs, dir, sha, }: {
|
|
20
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
21
|
+
dir: string;
|
|
22
|
+
sha: string;
|
|
23
|
+
}) => Promise<boolean>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Schema, Collection, Template as TinaTemplate } from '@tinacms/schema-tools';
|
|
2
|
+
import { buildDotTinaFiles } from './build';
|
|
3
|
+
export { resolve } from './resolve';
|
|
4
|
+
export { transformDocumentIntoPayload } from './resolver';
|
|
5
|
+
export * from './resolver/error';
|
|
6
|
+
export { TinaLevelClient } from './level/tinaLevel';
|
|
7
|
+
export type { Level } from './database/level';
|
|
8
|
+
export type { QueryOptions, OnDeleteCallback, OnPutCallback, DatabaseArgs, GitProvider, CreateDatabase, } from './database';
|
|
9
|
+
export { Database, createDatabaseInternal, createDatabase, createLocalDatabase, } from './database';
|
|
10
|
+
import type { Config } from '@tinacms/schema-tools';
|
|
11
|
+
export { getChangedFiles, getSha, shaExists } from './git';
|
|
12
|
+
export * from './auth/utils';
|
|
13
|
+
export { sequential, assertShape } from './util';
|
|
14
|
+
export { loadAndParseWithAliases, stringifyFile, parseFile, scanAllContent, scanContentByPaths, transformDocument, } from './database/util';
|
|
15
|
+
export { createSchema } from './schema/createSchema';
|
|
16
|
+
export { buildDotTinaFiles };
|
|
17
|
+
export type DummyType = unknown;
|
|
18
|
+
export declare const buildSchema: (config: Config, flags?: string[]) => Promise<{
|
|
19
|
+
graphQLSchema: {
|
|
20
|
+
kind: "Document";
|
|
21
|
+
definitions: any;
|
|
22
|
+
};
|
|
23
|
+
tinaSchema: import("@tinacms/schema-tools").TinaSchema;
|
|
24
|
+
lookup: Record<string, import("./database").LookupMapType>;
|
|
25
|
+
fragDoc: string;
|
|
26
|
+
queryDoc: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type TinaSchema = Schema;
|
|
29
|
+
export type { TinaTemplate, Schema, Collection };
|
|
30
|
+
export { FilesystemBridge, AuditFileSystemBridge, } from './database/bridge/filesystem';
|
|
31
|
+
export { IsomorphicBridge } from './database/bridge/isomorphic';
|
|
32
|
+
export type { Bridge } from './database/bridge';
|