@tinacms/graphql 1.4.25 → 1.4.27
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 -37
- package/dist/error.d.ts +4 -0
- package/dist/git/index.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +126 -62
- package/dist/index.mjs +120 -58
- package/dist/resolver/index.d.ts +5 -0
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,37 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
and
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
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
|
+
}
|
package/dist/git/index.d.ts
CHANGED
|
@@ -16,3 +16,8 @@ export declare const getChangedFiles: ({ fs, dir, from, to, pathFilter, }: {
|
|
|
16
16
|
modified: any[];
|
|
17
17
|
deleted: any[];
|
|
18
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
CHANGED
|
@@ -7,7 +7,7 @@ export { createDatabase } from './database';
|
|
|
7
7
|
export { TinaLevelClient } from './level/tinaLevel';
|
|
8
8
|
export type { QueryOptions, Database, OnDeleteCallback, OnPutCallback, CreateDatabase, } from './database';
|
|
9
9
|
import type { Config } from '@tinacms/schema-tools';
|
|
10
|
-
export { getChangedFiles, getSha } from './git';
|
|
10
|
+
export { getChangedFiles, getSha, shaExists } from './git';
|
|
11
11
|
export { sequential, assertShape } from './util';
|
|
12
12
|
export { loadAndParseWithAliases, stringifyFile, parseFile, scanAllContent, scanContentByPaths, transformDocument, } from './database/util';
|
|
13
13
|
export { createSchema } from './schema/createSchema';
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(src_exports, {
|
|
|
47
47
|
scanAllContent: () => scanAllContent,
|
|
48
48
|
scanContentByPaths: () => scanContentByPaths,
|
|
49
49
|
sequential: () => sequential,
|
|
50
|
+
shaExists: () => shaExists,
|
|
50
51
|
stringifyFile: () => stringifyFile,
|
|
51
52
|
transformDocument: () => transformDocument,
|
|
52
53
|
transformDocumentIntoPayload: () => transformDocumentIntoPayload
|
|
@@ -1573,7 +1574,12 @@ var Builder = class {
|
|
|
1573
1574
|
[NAMER.createName([collection.name])]: "create",
|
|
1574
1575
|
[NAMER.updateName([collection.name])]: "update"
|
|
1575
1576
|
});
|
|
1576
|
-
return astBuilder.FieldDefinition({
|
|
1577
|
+
return astBuilder.FieldDefinition({
|
|
1578
|
+
type,
|
|
1579
|
+
name,
|
|
1580
|
+
args,
|
|
1581
|
+
required: true
|
|
1582
|
+
});
|
|
1577
1583
|
};
|
|
1578
1584
|
this.collectionFragment = async (collection) => {
|
|
1579
1585
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -1591,6 +1597,10 @@ var Builder = class {
|
|
|
1591
1597
|
this._getCollectionFragmentSelections = async (collection, depth) => {
|
|
1592
1598
|
var _a;
|
|
1593
1599
|
const selections = [];
|
|
1600
|
+
selections.push({
|
|
1601
|
+
name: { kind: "Name", value: "__typename" },
|
|
1602
|
+
kind: "Field"
|
|
1603
|
+
});
|
|
1594
1604
|
if (((_a = collection.fields) == null ? void 0 : _a.length) > 0) {
|
|
1595
1605
|
await sequential(collection.fields, async (x) => {
|
|
1596
1606
|
const field = await this._buildFieldNodeForFragments(x, depth);
|
|
@@ -2585,7 +2595,7 @@ var validateField = async (field) => {
|
|
|
2585
2595
|
// package.json
|
|
2586
2596
|
var package_default = {
|
|
2587
2597
|
name: "@tinacms/graphql",
|
|
2588
|
-
version: "1.4.
|
|
2598
|
+
version: "1.4.27",
|
|
2589
2599
|
main: "dist/index.js",
|
|
2590
2600
|
module: "dist/index.mjs",
|
|
2591
2601
|
typings: "dist/index.d.ts",
|
|
@@ -2858,7 +2868,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
2858
2868
|
};
|
|
2859
2869
|
|
|
2860
2870
|
// src/resolve.ts
|
|
2861
|
-
var
|
|
2871
|
+
var import_graphql5 = require("graphql");
|
|
2862
2872
|
|
|
2863
2873
|
// src/resolver/index.ts
|
|
2864
2874
|
var import_path3 = __toESM(require("path"));
|
|
@@ -3337,40 +3347,44 @@ ${$_body}`,
|
|
|
3337
3347
|
};
|
|
3338
3348
|
var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
3339
3349
|
var _a, _b;
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3350
|
+
try {
|
|
3351
|
+
switch (format) {
|
|
3352
|
+
case ".markdown":
|
|
3353
|
+
case ".mdx":
|
|
3354
|
+
case ".md":
|
|
3355
|
+
const contentJSON = (0, import_gray_matter.default)(content || "", {
|
|
3356
|
+
language: (_a = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterFormat) != null ? _a : "yaml",
|
|
3357
|
+
delimiters: (_b = markdownParseConfig == null ? void 0 : markdownParseConfig.frontmatterDelimiters) != null ? _b : "---",
|
|
3358
|
+
engines: matterEngines
|
|
3359
|
+
});
|
|
3360
|
+
const markdownData = {
|
|
3361
|
+
...contentJSON.data,
|
|
3362
|
+
$_body: contentJSON.content
|
|
3363
|
+
};
|
|
3364
|
+
assertShape(markdownData, yupSchema);
|
|
3365
|
+
return markdownData;
|
|
3366
|
+
case ".json":
|
|
3367
|
+
if (!content) {
|
|
3368
|
+
return {};
|
|
3369
|
+
}
|
|
3370
|
+
return JSON.parse(content);
|
|
3371
|
+
case ".toml":
|
|
3372
|
+
if (!content) {
|
|
3373
|
+
return {};
|
|
3374
|
+
}
|
|
3375
|
+
return import_toml.default.parse(content);
|
|
3376
|
+
case ".yaml":
|
|
3377
|
+
case ".yml":
|
|
3378
|
+
if (!content) {
|
|
3379
|
+
return {};
|
|
3380
|
+
}
|
|
3381
|
+
return import_js_yaml.default.safeLoad(content);
|
|
3382
|
+
}
|
|
3383
|
+
} catch (e) {
|
|
3384
|
+
console.error(e);
|
|
3385
|
+
throw e;
|
|
3373
3386
|
}
|
|
3387
|
+
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3374
3388
|
};
|
|
3375
3389
|
var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
3376
3390
|
const warnings = [];
|
|
@@ -4464,7 +4478,7 @@ var Resolver = class {
|
|
|
4464
4478
|
isCollectionSpecific
|
|
4465
4479
|
}) => {
|
|
4466
4480
|
const doc = await this.getDocument(realPath);
|
|
4467
|
-
const oldDoc = (doc == null ? void 0 : doc._rawData) || {};
|
|
4481
|
+
const oldDoc = this.resolveLegacyValues((doc == null ? void 0 : doc._rawData) || {}, collection);
|
|
4468
4482
|
if (isAddPendingDocument === true) {
|
|
4469
4483
|
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
4470
4484
|
const params2 = this.buildParams(args);
|
|
@@ -4509,6 +4523,38 @@ var Resolver = class {
|
|
|
4509
4523
|
await this.database.put(realPath, { ...oldDoc, ...params }, collection.name);
|
|
4510
4524
|
return this.getDocument(realPath);
|
|
4511
4525
|
};
|
|
4526
|
+
this.resolveLegacyValues = (oldDoc, collection) => {
|
|
4527
|
+
const legacyValues = {};
|
|
4528
|
+
Object.entries(oldDoc).forEach(([key, value]) => {
|
|
4529
|
+
var _a;
|
|
4530
|
+
const reservedKeys = [
|
|
4531
|
+
"$_body",
|
|
4532
|
+
"_collection",
|
|
4533
|
+
"_keepTemplateKey",
|
|
4534
|
+
"_template",
|
|
4535
|
+
"_relativePath",
|
|
4536
|
+
"_id"
|
|
4537
|
+
];
|
|
4538
|
+
if (reservedKeys.includes(key)) {
|
|
4539
|
+
return;
|
|
4540
|
+
}
|
|
4541
|
+
if (oldDoc._template) {
|
|
4542
|
+
const template = (_a = collection.templates) == null ? void 0 : _a.find(
|
|
4543
|
+
({ name }) => name === oldDoc._template
|
|
4544
|
+
);
|
|
4545
|
+
if (template) {
|
|
4546
|
+
if (!template.fields.find(({ name }) => name === key)) {
|
|
4547
|
+
legacyValues[key] = value;
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
} else {
|
|
4551
|
+
if (!collection.fields.find(({ name }) => name === key)) {
|
|
4552
|
+
legacyValues[key] = value;
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
});
|
|
4556
|
+
return legacyValues;
|
|
4557
|
+
};
|
|
4512
4558
|
this.resolveDocument = async ({
|
|
4513
4559
|
args,
|
|
4514
4560
|
collection: collectionName,
|
|
@@ -4821,6 +4867,15 @@ var resolveDateInput = (value) => {
|
|
|
4821
4867
|
return date;
|
|
4822
4868
|
};
|
|
4823
4869
|
|
|
4870
|
+
// src/error.ts
|
|
4871
|
+
var import_graphql4 = require("graphql");
|
|
4872
|
+
var NotFoundError = class extends import_graphql4.GraphQLError {
|
|
4873
|
+
constructor(message, nodes, source, positions, path7, originalError, extensions) {
|
|
4874
|
+
super(message, nodes, source, positions, path7, originalError, extensions);
|
|
4875
|
+
this.name = "NotFoundError";
|
|
4876
|
+
}
|
|
4877
|
+
};
|
|
4878
|
+
|
|
4824
4879
|
// src/resolve.ts
|
|
4825
4880
|
var resolve = async ({
|
|
4826
4881
|
config,
|
|
@@ -4836,9 +4891,9 @@ var resolve = async ({
|
|
|
4836
4891
|
const verboseValue = verbose != null ? verbose : true;
|
|
4837
4892
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
4838
4893
|
if (!graphQLSchemaAst) {
|
|
4839
|
-
throw new
|
|
4894
|
+
throw new import_graphql5.GraphQLError(`GraphQL schema not found`);
|
|
4840
4895
|
}
|
|
4841
|
-
const graphQLSchema = (0,
|
|
4896
|
+
const graphQLSchema = (0, import_graphql5.buildASTSchema)(graphQLSchemaAst);
|
|
4842
4897
|
const tinaConfig = await database.getTinaSchema();
|
|
4843
4898
|
const tinaSchema = await createSchema({
|
|
4844
4899
|
schema: tinaConfig,
|
|
@@ -4850,7 +4905,7 @@ var resolve = async ({
|
|
|
4850
4905
|
tinaSchema,
|
|
4851
4906
|
isAudit: isAudit || false
|
|
4852
4907
|
});
|
|
4853
|
-
const res = await (0,
|
|
4908
|
+
const res = await (0, import_graphql5.graphql)({
|
|
4854
4909
|
schema: graphQLSchema,
|
|
4855
4910
|
source: query,
|
|
4856
4911
|
variableValues: variables,
|
|
@@ -4860,7 +4915,7 @@ var resolve = async ({
|
|
|
4860
4915
|
typeResolver: async (source, _args, info) => {
|
|
4861
4916
|
if (source.__typename)
|
|
4862
4917
|
return source.__typename;
|
|
4863
|
-
const namedType = (0,
|
|
4918
|
+
const namedType = (0, import_graphql5.getNamedType)(info.returnType).toString();
|
|
4864
4919
|
const lookup = await database.getLookup(namedType);
|
|
4865
4920
|
if (lookup.resolveType === "unionData") {
|
|
4866
4921
|
return lookup.typeMap[source._template];
|
|
@@ -4872,7 +4927,7 @@ var resolve = async ({
|
|
|
4872
4927
|
var _a2, _b, _c, _d;
|
|
4873
4928
|
try {
|
|
4874
4929
|
const args = JSON.parse(JSON.stringify(_args));
|
|
4875
|
-
const returnType = (0,
|
|
4930
|
+
const returnType = (0, import_graphql5.getNamedType)(info.returnType).toString();
|
|
4876
4931
|
const lookup = await database.getLookup(returnType);
|
|
4877
4932
|
const isMutation = info.parentType.toString() === "Mutation";
|
|
4878
4933
|
const value = source[info.fieldName];
|
|
@@ -5035,11 +5090,14 @@ var resolve = async ({
|
|
|
5035
5090
|
if (res.errors) {
|
|
5036
5091
|
if (!silenceErrors) {
|
|
5037
5092
|
res.errors.map((e) => {
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
console.error(
|
|
5041
|
-
|
|
5042
|
-
|
|
5093
|
+
if (e instanceof NotFoundError) {
|
|
5094
|
+
} else {
|
|
5095
|
+
console.error(e.toString());
|
|
5096
|
+
if (verboseValue) {
|
|
5097
|
+
console.error("More error context below");
|
|
5098
|
+
console.error(e.message);
|
|
5099
|
+
console.error(e);
|
|
5100
|
+
}
|
|
5043
5101
|
}
|
|
5044
5102
|
});
|
|
5045
5103
|
}
|
|
@@ -5049,7 +5107,7 @@ var resolve = async ({
|
|
|
5049
5107
|
if (!silenceErrors) {
|
|
5050
5108
|
console.error(e);
|
|
5051
5109
|
}
|
|
5052
|
-
if (e instanceof
|
|
5110
|
+
if (e instanceof import_graphql5.GraphQLError) {
|
|
5053
5111
|
return {
|
|
5054
5112
|
errors: [e]
|
|
5055
5113
|
};
|
|
@@ -5061,7 +5119,7 @@ var resolve = async ({
|
|
|
5061
5119
|
|
|
5062
5120
|
// src/database/index.ts
|
|
5063
5121
|
var import_path4 = __toESM(require("path"));
|
|
5064
|
-
var
|
|
5122
|
+
var import_graphql6 = require("graphql");
|
|
5065
5123
|
var import_micromatch2 = __toESM(require("micromatch"));
|
|
5066
5124
|
var import_js_sha12 = __toESM(require("js-sha1"));
|
|
5067
5125
|
var createDatabase = (config) => {
|
|
@@ -5107,7 +5165,7 @@ var Database = class {
|
|
|
5107
5165
|
SUBLEVEL_OPTIONS
|
|
5108
5166
|
).get((0, import_schema_tools3.normalizePath)(filepath));
|
|
5109
5167
|
if (!contentObject) {
|
|
5110
|
-
throw new
|
|
5168
|
+
throw new NotFoundError(`Unable to find record ${filepath}`);
|
|
5111
5169
|
}
|
|
5112
5170
|
return transformDocument(
|
|
5113
5171
|
filepath,
|
|
@@ -5121,7 +5179,7 @@ var Database = class {
|
|
|
5121
5179
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5122
5180
|
const collection = await this.collectionForPath(filepath);
|
|
5123
5181
|
if (!collection) {
|
|
5124
|
-
throw new
|
|
5182
|
+
throw new import_graphql6.GraphQLError(`Unable to find collection for ${filepath}`);
|
|
5125
5183
|
}
|
|
5126
5184
|
const stringifiedFile = await this.stringifyFile(
|
|
5127
5185
|
filepath,
|
|
@@ -5137,7 +5195,7 @@ var Database = class {
|
|
|
5137
5195
|
try {
|
|
5138
5196
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5139
5197
|
} catch (e) {
|
|
5140
|
-
throw new
|
|
5198
|
+
throw new import_graphql6.GraphQLError(
|
|
5141
5199
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5142
5200
|
null,
|
|
5143
5201
|
null,
|
|
@@ -5219,13 +5277,13 @@ var Database = class {
|
|
|
5219
5277
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5220
5278
|
const collection = await this.collectionForPath(filepath);
|
|
5221
5279
|
if (!collection) {
|
|
5222
|
-
throw new
|
|
5280
|
+
throw new import_graphql6.GraphQLError(`Unable to find collection for ${filepath}.`);
|
|
5223
5281
|
}
|
|
5224
5282
|
if (((_a = collection.match) == null ? void 0 : _a.exclude) || ((_b = collection.match) == null ? void 0 : _b.include)) {
|
|
5225
5283
|
const matches = this.tinaSchema.getMatches({ collection });
|
|
5226
5284
|
const match = import_micromatch2.default.isMatch(filepath, matches);
|
|
5227
5285
|
if (!match) {
|
|
5228
|
-
throw new
|
|
5286
|
+
throw new import_graphql6.GraphQLError(
|
|
5229
5287
|
`File ${filepath} does not match collection ${collection.name} glob ${matches.join(
|
|
5230
5288
|
","
|
|
5231
5289
|
)}. Please change the filename or update matches for ${collection.name} in your config file.`
|
|
@@ -5243,7 +5301,7 @@ var Database = class {
|
|
|
5243
5301
|
try {
|
|
5244
5302
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5245
5303
|
} catch (e) {
|
|
5246
|
-
throw new
|
|
5304
|
+
throw new import_graphql6.GraphQLError(
|
|
5247
5305
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5248
5306
|
null,
|
|
5249
5307
|
null,
|
|
@@ -5314,7 +5372,7 @@ var Database = class {
|
|
|
5314
5372
|
}
|
|
5315
5373
|
return true;
|
|
5316
5374
|
} catch (error) {
|
|
5317
|
-
if (error instanceof
|
|
5375
|
+
if (error instanceof import_graphql6.GraphQLError) {
|
|
5318
5376
|
throw error;
|
|
5319
5377
|
}
|
|
5320
5378
|
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
@@ -5822,7 +5880,7 @@ var Database = class {
|
|
|
5822
5880
|
try {
|
|
5823
5881
|
await this.onDelete((0, import_schema_tools3.normalizePath)(filepath));
|
|
5824
5882
|
} catch (e) {
|
|
5825
|
-
throw new
|
|
5883
|
+
throw new import_graphql6.GraphQLError(
|
|
5826
5884
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
5827
5885
|
null,
|
|
5828
5886
|
null,
|
|
@@ -5888,7 +5946,7 @@ var Database = class {
|
|
|
5888
5946
|
this.level = this.rootLevel.sublevel(version, SUBLEVEL_OPTIONS);
|
|
5889
5947
|
}
|
|
5890
5948
|
if (!this.level) {
|
|
5891
|
-
throw new
|
|
5949
|
+
throw new import_graphql6.GraphQLError("Error initializing LevelDB instance");
|
|
5892
5950
|
}
|
|
5893
5951
|
}
|
|
5894
5952
|
async getTemplateDetailsForFile(collection, data) {
|
|
@@ -5950,7 +6008,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
5950
6008
|
const tinaSchema = await database.getSchema();
|
|
5951
6009
|
let templateInfo = null;
|
|
5952
6010
|
if (collection) {
|
|
5953
|
-
templateInfo =
|
|
6011
|
+
templateInfo = tinaSchema.getTemplatesForCollectable(collection);
|
|
5954
6012
|
}
|
|
5955
6013
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
5956
6014
|
await sequential(documentPaths, async (filepath) => {
|
|
@@ -6188,6 +6246,11 @@ var getChangedFiles = async ({
|
|
|
6188
6246
|
});
|
|
6189
6247
|
return results;
|
|
6190
6248
|
};
|
|
6249
|
+
var shaExists = async ({
|
|
6250
|
+
fs: fs4,
|
|
6251
|
+
dir,
|
|
6252
|
+
sha: sha3
|
|
6253
|
+
}) => import_isomorphic_git.default.readCommit({ fs: fs4, dir, oid: sha3 }).then(() => true).catch(() => false);
|
|
6191
6254
|
|
|
6192
6255
|
// src/database/bridge/filesystem.ts
|
|
6193
6256
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
@@ -6245,7 +6308,7 @@ var import_isomorphic_git2 = __toESM(require("isomorphic-git"));
|
|
|
6245
6308
|
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
6246
6309
|
var import_glob_parent = __toESM(require("glob-parent"));
|
|
6247
6310
|
var import_normalize_path2 = __toESM(require("normalize-path"));
|
|
6248
|
-
var
|
|
6311
|
+
var import_graphql7 = require("graphql");
|
|
6249
6312
|
var import_path7 = require("path");
|
|
6250
6313
|
var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
|
|
6251
6314
|
var toUint8Array = (buf) => {
|
|
@@ -6451,7 +6514,7 @@ var IsomorphicBridge = class {
|
|
|
6451
6514
|
fullname: true
|
|
6452
6515
|
});
|
|
6453
6516
|
if (!ref) {
|
|
6454
|
-
throw new
|
|
6517
|
+
throw new import_graphql7.GraphQLError(
|
|
6455
6518
|
`Unable to determine current branch from HEAD`,
|
|
6456
6519
|
null,
|
|
6457
6520
|
null,
|
|
@@ -6542,7 +6605,7 @@ var IsomorphicBridge = class {
|
|
|
6542
6605
|
await this.commitTree(updatedRootTreeOid, ref);
|
|
6543
6606
|
break;
|
|
6544
6607
|
} else {
|
|
6545
|
-
throw new
|
|
6608
|
+
throw new import_graphql7.GraphQLError(
|
|
6546
6609
|
`Unable to resolve path: ${filepath}`,
|
|
6547
6610
|
null,
|
|
6548
6611
|
null,
|
|
@@ -6658,6 +6721,7 @@ var buildSchema = async (config, flags) => {
|
|
|
6658
6721
|
scanAllContent,
|
|
6659
6722
|
scanContentByPaths,
|
|
6660
6723
|
sequential,
|
|
6724
|
+
shaExists,
|
|
6661
6725
|
stringifyFile,
|
|
6662
6726
|
transformDocument,
|
|
6663
6727
|
transformDocumentIntoPayload
|
package/dist/index.mjs
CHANGED
|
@@ -1518,7 +1518,12 @@ var Builder = class {
|
|
|
1518
1518
|
[NAMER.createName([collection.name])]: "create",
|
|
1519
1519
|
[NAMER.updateName([collection.name])]: "update"
|
|
1520
1520
|
});
|
|
1521
|
-
return astBuilder.FieldDefinition({
|
|
1521
|
+
return astBuilder.FieldDefinition({
|
|
1522
|
+
type,
|
|
1523
|
+
name,
|
|
1524
|
+
args,
|
|
1525
|
+
required: true
|
|
1526
|
+
});
|
|
1522
1527
|
};
|
|
1523
1528
|
this.collectionFragment = async (collection) => {
|
|
1524
1529
|
const name = NAMER.dataTypeName(collection.namespace);
|
|
@@ -1535,6 +1540,10 @@ var Builder = class {
|
|
|
1535
1540
|
};
|
|
1536
1541
|
this._getCollectionFragmentSelections = async (collection, depth) => {
|
|
1537
1542
|
const selections = [];
|
|
1543
|
+
selections.push({
|
|
1544
|
+
name: { kind: "Name", value: "__typename" },
|
|
1545
|
+
kind: "Field"
|
|
1546
|
+
});
|
|
1538
1547
|
if (collection.fields?.length > 0) {
|
|
1539
1548
|
await sequential(collection.fields, async (x) => {
|
|
1540
1549
|
const field = await this._buildFieldNodeForFragments(x, depth);
|
|
@@ -2526,7 +2535,7 @@ var validateField = async (field) => {
|
|
|
2526
2535
|
// package.json
|
|
2527
2536
|
var package_default = {
|
|
2528
2537
|
name: "@tinacms/graphql",
|
|
2529
|
-
version: "1.4.
|
|
2538
|
+
version: "1.4.27",
|
|
2530
2539
|
main: "dist/index.js",
|
|
2531
2540
|
module: "dist/index.mjs",
|
|
2532
2541
|
typings: "dist/index.d.ts",
|
|
@@ -2798,7 +2807,7 @@ var _buildSchema = async (builder, tinaSchema) => {
|
|
|
2798
2807
|
};
|
|
2799
2808
|
|
|
2800
2809
|
// src/resolve.ts
|
|
2801
|
-
import { graphql, buildASTSchema, getNamedType, GraphQLError as
|
|
2810
|
+
import { graphql, buildASTSchema, getNamedType, GraphQLError as GraphQLError4 } from "graphql";
|
|
2802
2811
|
|
|
2803
2812
|
// src/resolver/index.ts
|
|
2804
2813
|
import path3 from "path";
|
|
@@ -3274,40 +3283,44 @@ ${$_body}`,
|
|
|
3274
3283
|
}
|
|
3275
3284
|
};
|
|
3276
3285
|
var parseFile = (content, format, yupSchema, markdownParseConfig) => {
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3286
|
+
try {
|
|
3287
|
+
switch (format) {
|
|
3288
|
+
case ".markdown":
|
|
3289
|
+
case ".mdx":
|
|
3290
|
+
case ".md":
|
|
3291
|
+
const contentJSON = matter(content || "", {
|
|
3292
|
+
language: markdownParseConfig?.frontmatterFormat ?? "yaml",
|
|
3293
|
+
delimiters: markdownParseConfig?.frontmatterDelimiters ?? "---",
|
|
3294
|
+
engines: matterEngines
|
|
3295
|
+
});
|
|
3296
|
+
const markdownData = {
|
|
3297
|
+
...contentJSON.data,
|
|
3298
|
+
$_body: contentJSON.content
|
|
3299
|
+
};
|
|
3300
|
+
assertShape(markdownData, yupSchema);
|
|
3301
|
+
return markdownData;
|
|
3302
|
+
case ".json":
|
|
3303
|
+
if (!content) {
|
|
3304
|
+
return {};
|
|
3305
|
+
}
|
|
3306
|
+
return JSON.parse(content);
|
|
3307
|
+
case ".toml":
|
|
3308
|
+
if (!content) {
|
|
3309
|
+
return {};
|
|
3310
|
+
}
|
|
3311
|
+
return toml.parse(content);
|
|
3312
|
+
case ".yaml":
|
|
3313
|
+
case ".yml":
|
|
3314
|
+
if (!content) {
|
|
3315
|
+
return {};
|
|
3316
|
+
}
|
|
3317
|
+
return yaml.safeLoad(content);
|
|
3318
|
+
}
|
|
3319
|
+
} catch (e) {
|
|
3320
|
+
console.error(e);
|
|
3321
|
+
throw e;
|
|
3310
3322
|
}
|
|
3323
|
+
throw new Error(`Must specify a valid format, got ${format}`);
|
|
3311
3324
|
};
|
|
3312
3325
|
var scanAllContent = async (tinaSchema, bridge, callback) => {
|
|
3313
3326
|
const warnings = [];
|
|
@@ -4400,7 +4413,7 @@ var Resolver = class {
|
|
|
4400
4413
|
isCollectionSpecific
|
|
4401
4414
|
}) => {
|
|
4402
4415
|
const doc = await this.getDocument(realPath);
|
|
4403
|
-
const oldDoc = doc?._rawData || {};
|
|
4416
|
+
const oldDoc = this.resolveLegacyValues(doc?._rawData || {}, collection);
|
|
4404
4417
|
if (isAddPendingDocument === true) {
|
|
4405
4418
|
const templateInfo = this.tinaSchema.getTemplatesForCollectable(collection);
|
|
4406
4419
|
const params2 = this.buildParams(args);
|
|
@@ -4445,6 +4458,37 @@ var Resolver = class {
|
|
|
4445
4458
|
await this.database.put(realPath, { ...oldDoc, ...params }, collection.name);
|
|
4446
4459
|
return this.getDocument(realPath);
|
|
4447
4460
|
};
|
|
4461
|
+
this.resolveLegacyValues = (oldDoc, collection) => {
|
|
4462
|
+
const legacyValues = {};
|
|
4463
|
+
Object.entries(oldDoc).forEach(([key, value]) => {
|
|
4464
|
+
const reservedKeys = [
|
|
4465
|
+
"$_body",
|
|
4466
|
+
"_collection",
|
|
4467
|
+
"_keepTemplateKey",
|
|
4468
|
+
"_template",
|
|
4469
|
+
"_relativePath",
|
|
4470
|
+
"_id"
|
|
4471
|
+
];
|
|
4472
|
+
if (reservedKeys.includes(key)) {
|
|
4473
|
+
return;
|
|
4474
|
+
}
|
|
4475
|
+
if (oldDoc._template) {
|
|
4476
|
+
const template = collection.templates?.find(
|
|
4477
|
+
({ name }) => name === oldDoc._template
|
|
4478
|
+
);
|
|
4479
|
+
if (template) {
|
|
4480
|
+
if (!template.fields.find(({ name }) => name === key)) {
|
|
4481
|
+
legacyValues[key] = value;
|
|
4482
|
+
}
|
|
4483
|
+
}
|
|
4484
|
+
} else {
|
|
4485
|
+
if (!collection.fields.find(({ name }) => name === key)) {
|
|
4486
|
+
legacyValues[key] = value;
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
});
|
|
4490
|
+
return legacyValues;
|
|
4491
|
+
};
|
|
4448
4492
|
this.resolveDocument = async ({
|
|
4449
4493
|
args,
|
|
4450
4494
|
collection: collectionName,
|
|
@@ -4757,6 +4801,15 @@ var resolveDateInput = (value) => {
|
|
|
4757
4801
|
return date;
|
|
4758
4802
|
};
|
|
4759
4803
|
|
|
4804
|
+
// src/error.ts
|
|
4805
|
+
import { GraphQLError as GraphQLError3 } from "graphql";
|
|
4806
|
+
var NotFoundError = class extends GraphQLError3 {
|
|
4807
|
+
constructor(message, nodes, source, positions, path7, originalError, extensions) {
|
|
4808
|
+
super(message, nodes, source, positions, path7, originalError, extensions);
|
|
4809
|
+
this.name = "NotFoundError";
|
|
4810
|
+
}
|
|
4811
|
+
};
|
|
4812
|
+
|
|
4760
4813
|
// src/resolve.ts
|
|
4761
4814
|
var resolve = async ({
|
|
4762
4815
|
config,
|
|
@@ -4771,7 +4824,7 @@ var resolve = async ({
|
|
|
4771
4824
|
const verboseValue = verbose ?? true;
|
|
4772
4825
|
const graphQLSchemaAst = await database.getGraphQLSchema();
|
|
4773
4826
|
if (!graphQLSchemaAst) {
|
|
4774
|
-
throw new
|
|
4827
|
+
throw new GraphQLError4(`GraphQL schema not found`);
|
|
4775
4828
|
}
|
|
4776
4829
|
const graphQLSchema = buildASTSchema(graphQLSchemaAst);
|
|
4777
4830
|
const tinaConfig = await database.getTinaSchema();
|
|
@@ -4967,11 +5020,14 @@ var resolve = async ({
|
|
|
4967
5020
|
if (res.errors) {
|
|
4968
5021
|
if (!silenceErrors) {
|
|
4969
5022
|
res.errors.map((e) => {
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
console.error(
|
|
4973
|
-
|
|
4974
|
-
|
|
5023
|
+
if (e instanceof NotFoundError) {
|
|
5024
|
+
} else {
|
|
5025
|
+
console.error(e.toString());
|
|
5026
|
+
if (verboseValue) {
|
|
5027
|
+
console.error("More error context below");
|
|
5028
|
+
console.error(e.message);
|
|
5029
|
+
console.error(e);
|
|
5030
|
+
}
|
|
4975
5031
|
}
|
|
4976
5032
|
});
|
|
4977
5033
|
}
|
|
@@ -4981,7 +5037,7 @@ var resolve = async ({
|
|
|
4981
5037
|
if (!silenceErrors) {
|
|
4982
5038
|
console.error(e);
|
|
4983
5039
|
}
|
|
4984
|
-
if (e instanceof
|
|
5040
|
+
if (e instanceof GraphQLError4) {
|
|
4985
5041
|
return {
|
|
4986
5042
|
errors: [e]
|
|
4987
5043
|
};
|
|
@@ -4993,7 +5049,7 @@ var resolve = async ({
|
|
|
4993
5049
|
|
|
4994
5050
|
// src/database/index.ts
|
|
4995
5051
|
import path4 from "path";
|
|
4996
|
-
import { GraphQLError as
|
|
5052
|
+
import { GraphQLError as GraphQLError5 } from "graphql";
|
|
4997
5053
|
import micromatch2 from "micromatch";
|
|
4998
5054
|
import sha2 from "js-sha1";
|
|
4999
5055
|
var createDatabase = (config) => {
|
|
@@ -5039,7 +5095,7 @@ var Database = class {
|
|
|
5039
5095
|
SUBLEVEL_OPTIONS
|
|
5040
5096
|
).get(normalizePath(filepath));
|
|
5041
5097
|
if (!contentObject) {
|
|
5042
|
-
throw new
|
|
5098
|
+
throw new NotFoundError(`Unable to find record ${filepath}`);
|
|
5043
5099
|
}
|
|
5044
5100
|
return transformDocument(
|
|
5045
5101
|
filepath,
|
|
@@ -5053,7 +5109,7 @@ var Database = class {
|
|
|
5053
5109
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5054
5110
|
const collection = await this.collectionForPath(filepath);
|
|
5055
5111
|
if (!collection) {
|
|
5056
|
-
throw new
|
|
5112
|
+
throw new GraphQLError5(`Unable to find collection for ${filepath}`);
|
|
5057
5113
|
}
|
|
5058
5114
|
const stringifiedFile = await this.stringifyFile(
|
|
5059
5115
|
filepath,
|
|
@@ -5069,7 +5125,7 @@ var Database = class {
|
|
|
5069
5125
|
try {
|
|
5070
5126
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5071
5127
|
} catch (e) {
|
|
5072
|
-
throw new
|
|
5128
|
+
throw new GraphQLError5(
|
|
5073
5129
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5074
5130
|
null,
|
|
5075
5131
|
null,
|
|
@@ -5150,13 +5206,13 @@ var Database = class {
|
|
|
5150
5206
|
const dataFields = await this.formatBodyOnPayload(filepath, data);
|
|
5151
5207
|
const collection = await this.collectionForPath(filepath);
|
|
5152
5208
|
if (!collection) {
|
|
5153
|
-
throw new
|
|
5209
|
+
throw new GraphQLError5(`Unable to find collection for ${filepath}.`);
|
|
5154
5210
|
}
|
|
5155
5211
|
if (collection.match?.exclude || collection.match?.include) {
|
|
5156
5212
|
const matches = this.tinaSchema.getMatches({ collection });
|
|
5157
5213
|
const match = micromatch2.isMatch(filepath, matches);
|
|
5158
5214
|
if (!match) {
|
|
5159
|
-
throw new
|
|
5215
|
+
throw new GraphQLError5(
|
|
5160
5216
|
`File ${filepath} does not match collection ${collection.name} glob ${matches.join(
|
|
5161
5217
|
","
|
|
5162
5218
|
)}. Please change the filename or update matches for ${collection.name} in your config file.`
|
|
@@ -5174,7 +5230,7 @@ var Database = class {
|
|
|
5174
5230
|
try {
|
|
5175
5231
|
await this.onPut(normalizedPath, stringifiedFile);
|
|
5176
5232
|
} catch (e) {
|
|
5177
|
-
throw new
|
|
5233
|
+
throw new GraphQLError5(
|
|
5178
5234
|
`Error running onPut hook for ${filepath}: ${e}`,
|
|
5179
5235
|
null,
|
|
5180
5236
|
null,
|
|
@@ -5245,7 +5301,7 @@ var Database = class {
|
|
|
5245
5301
|
}
|
|
5246
5302
|
return true;
|
|
5247
5303
|
} catch (error) {
|
|
5248
|
-
if (error instanceof
|
|
5304
|
+
if (error instanceof GraphQLError5) {
|
|
5249
5305
|
throw error;
|
|
5250
5306
|
}
|
|
5251
5307
|
throw new TinaFetchError(`Error in PUT for ${filepath}`, {
|
|
@@ -5752,7 +5808,7 @@ var Database = class {
|
|
|
5752
5808
|
try {
|
|
5753
5809
|
await this.onDelete(normalizePath(filepath));
|
|
5754
5810
|
} catch (e) {
|
|
5755
|
-
throw new
|
|
5811
|
+
throw new GraphQLError5(
|
|
5756
5812
|
`Error running onDelete hook for ${filepath}: ${e}`,
|
|
5757
5813
|
null,
|
|
5758
5814
|
null,
|
|
@@ -5818,7 +5874,7 @@ var Database = class {
|
|
|
5818
5874
|
this.level = this.rootLevel.sublevel(version, SUBLEVEL_OPTIONS);
|
|
5819
5875
|
}
|
|
5820
5876
|
if (!this.level) {
|
|
5821
|
-
throw new
|
|
5877
|
+
throw new GraphQLError5("Error initializing LevelDB instance");
|
|
5822
5878
|
}
|
|
5823
5879
|
}
|
|
5824
5880
|
async getTemplateDetailsForFile(collection, data) {
|
|
@@ -5880,7 +5936,7 @@ var _indexContent = async (database, level, documentPaths, enqueueOps, collectio
|
|
|
5880
5936
|
const tinaSchema = await database.getSchema();
|
|
5881
5937
|
let templateInfo = null;
|
|
5882
5938
|
if (collection) {
|
|
5883
|
-
templateInfo =
|
|
5939
|
+
templateInfo = tinaSchema.getTemplatesForCollectable(collection);
|
|
5884
5940
|
}
|
|
5885
5941
|
const folderTreeBuilder = new FolderTreeBuilder();
|
|
5886
5942
|
await sequential(documentPaths, async (filepath) => {
|
|
@@ -6118,6 +6174,11 @@ var getChangedFiles = async ({
|
|
|
6118
6174
|
});
|
|
6119
6175
|
return results;
|
|
6120
6176
|
};
|
|
6177
|
+
var shaExists = async ({
|
|
6178
|
+
fs: fs4,
|
|
6179
|
+
dir,
|
|
6180
|
+
sha: sha3
|
|
6181
|
+
}) => git.readCommit({ fs: fs4, dir, oid: sha3 }).then(() => true).catch(() => false);
|
|
6121
6182
|
|
|
6122
6183
|
// src/database/bridge/filesystem.ts
|
|
6123
6184
|
import fs2 from "fs-extra";
|
|
@@ -6175,7 +6236,7 @@ import git2 from "isomorphic-git";
|
|
|
6175
6236
|
import fs3 from "fs-extra";
|
|
6176
6237
|
import globParent from "glob-parent";
|
|
6177
6238
|
import normalize2 from "normalize-path";
|
|
6178
|
-
import { GraphQLError as
|
|
6239
|
+
import { GraphQLError as GraphQLError6 } from "graphql";
|
|
6179
6240
|
import { dirname } from "path";
|
|
6180
6241
|
var flat = typeof Array.prototype.flat === "undefined" ? (entries) => entries.reduce((acc, x) => acc.concat(x), []) : (entries) => entries.flat();
|
|
6181
6242
|
var toUint8Array = (buf) => {
|
|
@@ -6381,7 +6442,7 @@ var IsomorphicBridge = class {
|
|
|
6381
6442
|
fullname: true
|
|
6382
6443
|
});
|
|
6383
6444
|
if (!ref) {
|
|
6384
|
-
throw new
|
|
6445
|
+
throw new GraphQLError6(
|
|
6385
6446
|
`Unable to determine current branch from HEAD`,
|
|
6386
6447
|
null,
|
|
6387
6448
|
null,
|
|
@@ -6472,7 +6533,7 @@ var IsomorphicBridge = class {
|
|
|
6472
6533
|
await this.commitTree(updatedRootTreeOid, ref);
|
|
6473
6534
|
break;
|
|
6474
6535
|
} else {
|
|
6475
|
-
throw new
|
|
6536
|
+
throw new GraphQLError6(
|
|
6476
6537
|
`Unable to resolve path: ${filepath}`,
|
|
6477
6538
|
null,
|
|
6478
6539
|
null,
|
|
@@ -6587,6 +6648,7 @@ export {
|
|
|
6587
6648
|
scanAllContent,
|
|
6588
6649
|
scanContentByPaths,
|
|
6589
6650
|
sequential,
|
|
6651
|
+
shaExists,
|
|
6590
6652
|
stringifyFile,
|
|
6591
6653
|
transformDocument,
|
|
6592
6654
|
transformDocumentIntoPayload
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -228,6 +228,11 @@ export declare class Resolver {
|
|
|
228
228
|
__typename: string;
|
|
229
229
|
id: string;
|
|
230
230
|
}>;
|
|
231
|
+
/**
|
|
232
|
+
* Returns top-level fields which are not defined in the collection, so their
|
|
233
|
+
* values are not eliminated from Tina when new values are saved
|
|
234
|
+
*/
|
|
235
|
+
resolveLegacyValues: (oldDoc: any, collection: Collection<true>) => {};
|
|
231
236
|
resolveDocument: ({ args, collection: collectionName, isMutation, isCreation, isDeletion, isAddPendingDocument, isCollectionSpecific, isUpdateName, }: {
|
|
232
237
|
args: unknown;
|
|
233
238
|
collection?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.27",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@iarna/toml": "^2.2.5",
|
|
27
|
-
"@tinacms/mdx": "1.3.
|
|
28
|
-
"@tinacms/schema-tools": "1.4.
|
|
27
|
+
"@tinacms/mdx": "1.3.20",
|
|
28
|
+
"@tinacms/schema-tools": "1.4.13",
|
|
29
29
|
"abstract-level": "^1.0.3",
|
|
30
30
|
"body-parser": "^1.19.0",
|
|
31
31
|
"cors": "^2.8.5",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"directory": "packages/tina-graphql"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tinacms/schema-tools": "1.4.
|
|
60
|
+
"@tinacms/schema-tools": "1.4.13",
|
|
61
61
|
"@tinacms/scripts": "1.1.2",
|
|
62
62
|
"@types/cors": "^2.8.7",
|
|
63
63
|
"@types/estree": "^0.0.50",
|