@tinacms/datalayer 1.0.0 → 1.1.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/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@tinacms/datalayer",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
+ "module": "dist/index.es.js",
5
6
  "typings": "dist/index.d.ts",
6
7
  "files": [
7
8
  "package.json",
8
9
  "dist"
9
10
  ],
10
- "license": "Apache-2.0",
11
+ "exports": {
12
+ "import": "./dist/index.es.js",
13
+ "require": "./dist/index.js"
14
+ },
15
+ "license": "SEE LICENSE IN LICENSE",
11
16
  "buildConfig": {
12
17
  "entryPoints": [
13
18
  {
@@ -18,26 +23,7 @@
18
23
  ]
19
24
  },
20
25
  "dependencies": {
21
- "@octokit/auth-app": "^2.6.0",
22
- "@octokit/graphql": "^4.5.6",
23
- "@octokit/rest": "18.0.6",
24
- "encoding-down": "^7.1.0",
25
- "fast-glob": "^3.2.5",
26
- "fs-extra": "^9.0.1",
27
- "glob-parent": "^6.0.2",
28
- "graphql": "15.8.0",
29
- "gray-matter": "^4.0.2",
30
- "isomorphic-git": "^1.10.3",
31
- "js-yaml": "^3.14.0",
32
- "jsonpath-plus": "^6.0.1",
33
- "level": "^7.0.1",
34
- "leveldown": "^6.1.0",
35
- "levelup": "^5.1.1",
36
- "lodash": "^4.17.20",
37
- "memdown": "^6.1.1",
38
- "normalize-path": "^3.0.0",
39
- "prettier": "^2.2.1",
40
- "yup": "^0.32.9"
26
+ "@tinacms/graphql": "1.2.0"
41
27
  },
42
28
  "publishConfig": {
43
29
  "registry": "https://registry.npmjs.org"
@@ -47,7 +33,7 @@
47
33
  "directory": "packages/@tinacms/datalayer"
48
34
  },
49
35
  "devDependencies": {
50
- "@tinacms/scripts": "1.0.0",
36
+ "@tinacms/scripts": "1.0.2",
51
37
  "@types/fs-extra": "^9.0.2",
52
38
  "@types/jest": "^27.4.1",
53
39
  "@types/js-yaml": "^3.12.5",
@@ -1,34 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import type { Bridge } from './index';
14
- /**
15
- * This is the bridge from whatever datasource we need for I/O.
16
- * The basic example here is for the filesystem, one is needed
17
- * for Github has well.
18
- */
19
- export declare class FilesystemBridge implements Bridge {
20
- rootPath: string;
21
- constructor(rootPath: string);
22
- glob(pattern: string, extension: string): Promise<string[]>;
23
- supportsBuilding(): boolean;
24
- delete(filepath: string): Promise<void>;
25
- get(filepath: string): Promise<string>;
26
- putConfig(filepath: string, data: string): Promise<void>;
27
- put(filepath: string, data: string): Promise<void>;
28
- }
29
- /**
30
- * Same as the `FileSystemBridge` except it does not save files
31
- */
32
- export declare class AuditFileSystemBridge extends FilesystemBridge {
33
- put(filepath: string, data: string): Promise<void>;
34
- }
@@ -1,24 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- export interface Bridge {
14
- rootPath: string;
15
- glob(pattern: string, extension: string): Promise<string[]>;
16
- delete(filepath: string): Promise<void>;
17
- get(filepath: string): Promise<string>;
18
- put(filepath: string, data: string): Promise<void>;
19
- /**
20
- * Whether this bridge supports the ability to build the schema.
21
- */
22
- supportsBuilding(): boolean;
23
- putConfig(filepath: string, data: string): Promise<void>;
24
- }
@@ -1,108 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import { CallbackFsClient, PromiseFsClient } from 'isomorphic-git';
14
- import type { Bridge } from './index';
15
- export declare type IsomorphicGitBridgeOptions = {
16
- gitRoot: string;
17
- fsModule?: CallbackFsClient | PromiseFsClient;
18
- commitMessage?: string;
19
- author: {
20
- name: string;
21
- email: string;
22
- };
23
- committer?: {
24
- name: string;
25
- email: string;
26
- };
27
- ref?: string;
28
- onPut?: (filepath: string, data: string) => Promise<void>;
29
- onDelete?: (filepath: string) => Promise<void>;
30
- };
31
- /**
32
- * Bridge backed by isomorphic-git
33
- */
34
- export declare class IsomorphicBridge implements Bridge {
35
- rootPath: string;
36
- relativePath: string;
37
- gitRoot: string;
38
- fsModule: CallbackFsClient | PromiseFsClient;
39
- isomorphicConfig: {
40
- fs: CallbackFsClient | PromiseFsClient;
41
- dir: string;
42
- };
43
- commitMessage: string;
44
- author: {
45
- name: string;
46
- email: string;
47
- };
48
- committer: {
49
- name: string;
50
- email: string;
51
- };
52
- ref: string | undefined;
53
- private readonly onPut;
54
- private readonly onDelete;
55
- private cache;
56
- constructor(rootPath: string, { gitRoot, author, committer, fsModule, commitMessage, ref, onPut, onDelete, }: IsomorphicGitBridgeOptions);
57
- private getAuthor;
58
- private getCommitter;
59
- /**
60
- * Recursively populate paths matching `pattern` for the given `entry`
61
- *
62
- * @param pattern - pattern to filter paths by
63
- * @param entry - TreeEntry to start building list from
64
- * @param path - base path
65
- * @param results
66
- * @private
67
- */
68
- private listEntries;
69
- /**
70
- * For the specified path, returns an object with an array containing the parts of the path (pathParts)
71
- * and an array containing the WalkerEntry objects for the path parts (pathEntries). Any null elements in the
72
- * pathEntries are placeholders for non-existent entries.
73
- *
74
- * @param path - path being resolved
75
- * @param ref - ref to resolve path entries for
76
- * @private
77
- */
78
- private resolvePathEntries;
79
- /**
80
- * Updates tree entry and associated parent tree entries
81
- *
82
- * @param existingOid - the existing OID
83
- * @param updatedOid - the updated OID
84
- * @param path - the path of the entry being updated
85
- * @param type - the type of the entry being updated (blob or tree)
86
- * @param pathEntries - parent path entries
87
- * @param pathParts - parent path parts
88
- * @private
89
- */
90
- private updateTreeHierarchy;
91
- /**
92
- * Creates a commit for the specified tree and updates the specified ref to point to the commit
93
- *
94
- * @param treeSha - sha of the new tree
95
- * @param ref - the ref that should be updated
96
- * @private
97
- */
98
- private commitTree;
99
- private getRef;
100
- glob(pattern: string, extension: string): Promise<string[]>;
101
- supportsBuilding(): boolean;
102
- delete(filepath: string): Promise<void>;
103
- private qualifyPath;
104
- private unqualifyPath;
105
- get(filepath: string): Promise<string>;
106
- putConfig(filepath: string, data: string): Promise<void>;
107
- put(filepath: string, data: string): Promise<void>;
108
- }
@@ -1,34 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import { StoreQueryOptions, PutOptions, Store, StoreQueryResponse } from '.';
14
- export declare class FilesystemStore implements Store {
15
- rootPath: string;
16
- clear(): Promise<void>;
17
- print(): Promise<void>;
18
- constructor({ rootPath }: {
19
- rootPath?: string;
20
- });
21
- query(_queryOptions: StoreQueryOptions): Promise<StoreQueryResponse>;
22
- seed(): Promise<void>;
23
- get<T extends object>(filepath: string): Promise<T>;
24
- supportsSeeding(): boolean;
25
- supportsIndexing(): boolean;
26
- glob(pattern: string, callback: any, extension: any): Promise<any[]>;
27
- put(filepath: string, data: object, options?: PutOptions): Promise<void>;
28
- open(): Promise<void>;
29
- close(): Promise<void>;
30
- delete(filepath: any): Promise<void>;
31
- }
32
- export declare class AuditFilesystemStore extends FilesystemStore {
33
- put(_filepath: string, _data: object): Promise<void>;
34
- }
@@ -1,144 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import { FilterOperand } from '../../index';
14
- export declare const DEFAULT_COLLECTION_SORT_KEY = "__filepath__";
15
- export declare const INDEX_KEY_FIELD_SEPARATOR = "#";
16
- export declare const DEFAULT_NUMERIC_LPAD = 4;
17
- export declare enum OP {
18
- EQ = "eq",
19
- GT = "gt",
20
- LT = "lt",
21
- GTE = "gte",
22
- LTE = "lte",
23
- STARTS_WITH = "startsWith",
24
- IN = "in"
25
- }
26
- export declare type PadDefinition = {
27
- fillString: string;
28
- maxLength: number;
29
- };
30
- export declare type BinaryFilter = {
31
- pathExpression: string;
32
- rightOperand: FilterOperand;
33
- operator: OP.EQ | OP.GT | OP.LT | OP.GTE | OP.LTE | OP.STARTS_WITH | OP.IN;
34
- type: string;
35
- pad?: PadDefinition;
36
- };
37
- export declare type TernaryFilter = {
38
- pathExpression: string;
39
- leftOperand: FilterOperand;
40
- rightOperand: FilterOperand;
41
- leftOperator: OP.GTE | OP.GT;
42
- rightOperator: OP.LT | OP.LTE;
43
- type: string;
44
- pad?: PadDefinition;
45
- };
46
- /** Options for {@link Store.query} */
47
- export declare type StoreQueryOptions = {
48
- collection: string;
49
- indexDefinitions?: Record<string, IndexDefinition>;
50
- filterChain: (BinaryFilter | TernaryFilter)[];
51
- sort?: string;
52
- gt?: string;
53
- gte?: string;
54
- lt?: string;
55
- lte?: string;
56
- reverse?: boolean;
57
- limit?: number;
58
- };
59
- export declare type PageInfo = {
60
- hasPreviousPage: boolean;
61
- hasNextPage: boolean;
62
- startCursor: string;
63
- endCursor: string;
64
- };
65
- export declare type StoreQueryResponse = {
66
- edges: {
67
- cursor: string;
68
- path: string;
69
- }[];
70
- pageInfo: PageInfo;
71
- };
72
- export declare type IndexDefinition = {
73
- fields: {
74
- name: string;
75
- type?: string;
76
- pad?: PadDefinition;
77
- }[];
78
- };
79
- export declare type SeedOptions = {
80
- collection?: string;
81
- indexDefinitions?: Record<string, IndexDefinition>;
82
- includeTemplate?: boolean;
83
- keepTemplateKey?: boolean;
84
- };
85
- export declare type PutOptions = SeedOptions & {
86
- seed?: boolean;
87
- };
88
- export declare type DeleteOptions = SeedOptions & {
89
- seed?: boolean;
90
- };
91
- export interface Store {
92
- glob(pattern: string, hydrator?: (fullPath: string) => Promise<object>, extension?: string): Promise<string[]>;
93
- get<T extends object>(filepath: string): Promise<T>;
94
- delete(filepath: string, options?: DeleteOptions): Promise<void>;
95
- clear(): void;
96
- close(): void;
97
- open(): void;
98
- /**
99
- * Executes a query against a collection
100
- * @param queryOptions - options for the query
101
- * @returns the results of the query
102
- */
103
- query(queryOptions: StoreQueryOptions): Promise<StoreQueryResponse>;
104
- /**
105
- * In this context, seeding is the act of putting records and indexing data into an ephemeral
106
- * storage layer for use during the GraphQL runtime. What might seem suprising is that some stores
107
- * don't support seeding, this is because they're behaving more like a "bridge" (GithubStore and FilesystemStore).
108
- * Currently they're acting as a way to swap out true data-layer behavior with a backwards-compatible
109
- * "store". In the future, all stores should be able to query and seed data.
110
- *
111
- * At this time it seems that it would never make sense to be able to "query" without "seed"-ing, and
112
- * there'd be no value in "seeding" without "query"-ing.
113
- */
114
- seed(filepath: string, data: object, options?: PutOptions): Promise<void>;
115
- supportsSeeding(): boolean;
116
- /**
117
- * Whether this store supports the ability to index data.
118
- * Indexing data requires writing arbitrary keys/values to
119
- * the external service, so is not advisable to use for
120
- * something like Github, which would write commits to the
121
- * user's repo.
122
- */
123
- supportsIndexing(): boolean;
124
- put(filepath: string, data: object, options?: PutOptions): Promise<void>;
125
- }
126
- export declare type FilterCondition = {
127
- filterExpression: Record<string, FilterOperand>;
128
- filterPath: string;
129
- };
130
- export declare const makeFilterChain: ({ conditions, }: {
131
- conditions: FilterCondition[];
132
- }) => (BinaryFilter | TernaryFilter)[];
133
- export declare const makeFilter: ({ filterChain, }: {
134
- filterChain?: (BinaryFilter | TernaryFilter)[];
135
- }) => (values: Record<string, object | FilterOperand>) => boolean;
136
- declare type StringEscaper = <T extends string | string[]>(input: T) => T;
137
- export declare const makeStringEscaper: (regex: RegExp, replacement: string) => StringEscaper;
138
- export declare const coerceFilterChainOperands: (filterChain: (BinaryFilter | TernaryFilter)[], stringEscaper: StringEscaper) => (BinaryFilter | TernaryFilter)[];
139
- export declare const makeFilterSuffixes: (filterChain: (BinaryFilter | TernaryFilter)[], index: IndexDefinition) => {
140
- left?: string;
141
- right?: string;
142
- } | undefined;
143
- export declare const makeKeyForField: (definition: IndexDefinition, data: object, stringEscaper: StringEscaper, maxStringLength?: number) => string | null;
144
- export {};
@@ -1,32 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import type { StoreQueryOptions, StoreQueryResponse, PutOptions, DeleteOptions, SeedOptions, Store } from './index';
14
- import { LevelDB } from 'level';
15
- export declare class LevelStore implements Store {
16
- rootPath: any;
17
- db: LevelDB;
18
- useMemory: boolean;
19
- constructor(rootPath: string, useMemory?: boolean);
20
- query(queryOptions: StoreQueryOptions): Promise<StoreQueryResponse>;
21
- seed(filepath: string, data: object, options?: SeedOptions): Promise<void>;
22
- supportsSeeding(): boolean;
23
- supportsIndexing(): boolean;
24
- delete(filepath: string, options: DeleteOptions): Promise<void>;
25
- print(): Promise<void>;
26
- open(): Promise<void>;
27
- clear(): Promise<void>;
28
- glob(pattern: string, callback: any): Promise<any[]>;
29
- get(filepath: string): Promise<any>;
30
- close(): Promise<void>;
31
- put(filepath: string, data: object, options?: PutOptions): Promise<void>;
32
- }
@@ -1,16 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import * as yup from 'yup';
14
- export declare const stringifyFile: (content: object, format: FormatType | string, keepTemplateKey: boolean) => string;
15
- export declare const parseFile: <T extends object>(content: string, format: FormatType | string, yupSchema: (args: typeof yup) => yup.ObjectSchema<any>) => T;
16
- export declare type FormatType = 'json' | 'md' | 'mdx' | 'markdown';
package/dist/util.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
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.
12
- */
13
- import * as yup from 'yup';
14
- /**
15
- * Iterate through an array of promises sequentially, ensuring the order
16
- * is preserved.
17
- *
18
- * ```js
19
- * await sequential(templates, async (template) => {
20
- * await doSomething(template)
21
- * })
22
- * ```
23
- */
24
- export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
25
- export declare function assertShape<T extends unknown>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema, errorMessage?: string): asserts value is T;
26
- export declare const atob: (b64Encoded: string) => string;
27
- export declare const btoa: (string: string) => string;
28
- export declare const lastItem: (arr: (number | string)[]) => string | number;